@openadapter/koda 1.0.0-beta.18 → 1.0.0-beta.20

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.
@@ -1 +1 @@
1
- var g=Object.defineProperty;var a=(r,e)=>g(r,"name",{value:e,configurable:!0});import{createBashTool as $,createBashToolDefinition as z,createLocalBashOperations as H}from"./bash.js";import{createEditTool as Q,createEditToolDefinition as Y}from"./edit.js";import{withFileMutationQueue as q}from"./file-mutation-queue.js";import{createFindTool as J,createFindToolDefinition as K}from"./find.js";import{createGrepTool as P,createGrepToolDefinition as V}from"./grep.js";import{createLsTool as w,createLsToolDefinition as ee}from"./ls.js";import{createReadTool as te,createReadToolDefinition as ae}from"./read.js";import{DEFAULT_MAX_BYTES as oe,DEFAULT_MAX_LINES as ne,formatSize as le,truncateHead as fe,truncateLine as Te,truncateTail as ue}from"./truncate.js";import{createWriteTool as me,createWriteToolDefinition as he}from"./write.js";import{createBashTool as n,createBashToolDefinition as l}from"./bash.js";import{createEditTool as f,createEditToolDefinition as T}from"./edit.js";import{createFindTool as u,createFindToolDefinition as c}from"./find.js";import{createGrepTool as m,createGrepToolDefinition as h}from"./grep.js";import{createLsTool as s,createLsToolDefinition as D}from"./ls.js";import{createReadTool as i,createReadToolDefinition as o}from"./read.js";import{createWriteTool as d,createWriteToolDefinition as x}from"./write.js";const G=new Set(["read","bash","edit","write","grep","find","ls"]);function S(r,e,t){switch(r){case"read":return o(e,t?.read);case"bash":return l(e,t?.bash);case"edit":return T(e,t?.edit);case"write":return x(e,t?.write);case"grep":return h(e,t?.grep);case"find":return c(e,t?.find);case"ls":return D(e,t?.ls);default:throw new Error(`Unknown tool name: ${r}`)}}a(S,"createToolDefinition");function U(r,e,t){switch(r){case"read":return i(e,t?.read);case"bash":return n(e,t?.bash);case"edit":return f(e,t?.edit);case"write":return d(e,t?.write);case"grep":return m(e,t?.grep);case"find":return u(e,t?.find);case"ls":return s(e,t?.ls);default:throw new Error(`Unknown tool name: ${r}`)}}a(U,"createTool");function W(r,e){return[o(r,e?.read),l(r,e?.bash),T(r,e?.edit),x(r,e?.write)]}a(W,"createCodingToolDefinitions");function _(r,e){return[o(r,e?.read),h(r,e?.grep),c(r,e?.find),D(r,e?.ls)]}a(_,"createReadOnlyToolDefinitions");function M(r,e){return{read:o(r,e?.read),bash:l(r,e?.bash),edit:T(r,e?.edit),write:x(r,e?.write),grep:h(r,e?.grep),find:c(r,e?.find),ls:D(r,e?.ls)}}a(M,"createAllToolDefinitions");function O(r,e){return[i(r,e?.read),n(r,e?.bash),f(r,e?.edit),d(r,e?.write)]}a(O,"createCodingTools");function k(r,e){return[i(r,e?.read),m(r,e?.grep),u(r,e?.find),s(r,e?.ls)]}a(k,"createReadOnlyTools");function y(r,e){return{read:i(r,e?.read),bash:n(r,e?.bash),edit:f(r,e?.edit),write:d(r,e?.write),grep:m(r,e?.grep),find:u(r,e?.find),ls:s(r,e?.ls)}}a(y,"createAllTools");export{oe as DEFAULT_MAX_BYTES,ne as DEFAULT_MAX_LINES,G as allToolNames,M as createAllToolDefinitions,y as createAllTools,$ as createBashTool,z as createBashToolDefinition,W as createCodingToolDefinitions,O as createCodingTools,Q as createEditTool,Y as createEditToolDefinition,J as createFindTool,K as createFindToolDefinition,P as createGrepTool,V as createGrepToolDefinition,H as createLocalBashOperations,w as createLsTool,ee as createLsToolDefinition,_ as createReadOnlyToolDefinitions,k as createReadOnlyTools,te as createReadTool,ae as createReadToolDefinition,U as createTool,S as createToolDefinition,me as createWriteTool,he as createWriteToolDefinition,le as formatSize,fe as truncateHead,Te as truncateLine,ue as truncateTail,q as withFileMutationQueue};
1
+ var _=Object.defineProperty;var a=(r,e)=>_(r,"name",{value:e,configurable:!0});import{createBashTool as I,createBashToolDefinition as Q,createLocalBashOperations as Y}from"./bash.js";import{createEditTool as q,createEditToolDefinition as v}from"./edit.js";import{withFileMutationQueue as K}from"./file-mutation-queue.js";import{createFindTool as P,createFindToolDefinition as V}from"./find.js";import{createGrepTool as w,createGrepToolDefinition as ee}from"./grep.js";import{createLsTool as te,createLsToolDefinition as ae}from"./ls.js";import{createReadTool as ie,createReadToolDefinition as ne}from"./read.js";import{createRepoMapTool as fe,createRepoMapToolDefinition as Te}from"./repo-map.js";import{DEFAULT_MAX_BYTES as me,DEFAULT_MAX_LINES as ce,formatSize as pe,truncateHead as De,truncateLine as he,truncateTail as xe}from"./truncate.js";import{createWriteTool as de,createWriteToolDefinition as ge}from"./write.js";import{createBashTool as n,createBashToolDefinition as l}from"./bash.js";import{createEditTool as f,createEditToolDefinition as T}from"./edit.js";import{createFindTool as u,createFindToolDefinition as m}from"./find.js";import{createGrepTool as c,createGrepToolDefinition as p}from"./grep.js";import{createLsTool as D,createLsToolDefinition as h}from"./ls.js";import{createReadTool as o,createReadToolDefinition as i}from"./read.js";import{createRepoMapTool as d,createRepoMapToolDefinition as g}from"./repo-map.js";import{createWriteTool as x,createWriteToolDefinition as s}from"./write.js";const S=new Set(["read","bash","edit","write","grep","find","ls","repo_map"]);function U(r,e,t){switch(r){case"read":return i(e,t?.read);case"bash":return l(e,t?.bash);case"edit":return T(e,t?.edit);case"write":return s(e,t?.write);case"grep":return p(e,t?.grep);case"find":return m(e,t?.find);case"ls":return h(e,t?.ls);case"repo_map":return g(e,t?.repo_map);default:throw new Error(`Unknown tool name: ${r}`)}}a(U,"createToolDefinition");function W(r,e,t){switch(r){case"read":return o(e,t?.read);case"bash":return n(e,t?.bash);case"edit":return f(e,t?.edit);case"write":return x(e,t?.write);case"grep":return c(e,t?.grep);case"find":return u(e,t?.find);case"ls":return D(e,t?.ls);case"repo_map":return d(e,t?.repo_map);default:throw new Error(`Unknown tool name: ${r}`)}}a(W,"createTool");function O(r,e){return[i(r,e?.read),l(r,e?.bash),T(r,e?.edit),s(r,e?.write)]}a(O,"createCodingToolDefinitions");function k(r,e){return[i(r,e?.read),p(r,e?.grep),m(r,e?.find),h(r,e?.ls)]}a(k,"createReadOnlyToolDefinitions");function y(r,e){return{read:i(r,e?.read),bash:l(r,e?.bash),edit:T(r,e?.edit),write:s(r,e?.write),grep:p(r,e?.grep),find:m(r,e?.find),ls:h(r,e?.ls),repo_map:g(r,e?.repo_map)}}a(y,"createAllToolDefinitions");function C(r,e){return[o(r,e?.read),n(r,e?.bash),f(r,e?.edit),x(r,e?.write)]}a(C,"createCodingTools");function X(r,e){return[o(r,e?.read),c(r,e?.grep),u(r,e?.find),D(r,e?.ls)]}a(X,"createReadOnlyTools");function $(r,e){return{read:o(r,e?.read),bash:n(r,e?.bash),edit:f(r,e?.edit),write:x(r,e?.write),grep:c(r,e?.grep),find:u(r,e?.find),ls:D(r,e?.ls),repo_map:d(r,e?.repo_map)}}a($,"createAllTools");export{me as DEFAULT_MAX_BYTES,ce as DEFAULT_MAX_LINES,S as allToolNames,y as createAllToolDefinitions,$ as createAllTools,I as createBashTool,Q as createBashToolDefinition,O as createCodingToolDefinitions,C as createCodingTools,q as createEditTool,v as createEditToolDefinition,P as createFindTool,V as createFindToolDefinition,w as createGrepTool,ee as createGrepToolDefinition,Y as createLocalBashOperations,te as createLsTool,ae as createLsToolDefinition,k as createReadOnlyToolDefinitions,X as createReadOnlyTools,ie as createReadTool,ne as createReadToolDefinition,fe as createRepoMapTool,Te as createRepoMapToolDefinition,W as createTool,U as createToolDefinition,de as createWriteTool,ge as createWriteToolDefinition,pe as formatSize,De as truncateHead,he as truncateLine,xe as truncateTail,K as withFileMutationQueue};
@@ -0,0 +1,15 @@
1
+ import type { AgentTool } from "@openadapter/koda-agent-core";
2
+ import { type Static, Type } from "typebox";
3
+ import type { ToolDefinition } from "../extensions/types.ts";
4
+ declare const repoMapSchema: Type.TObject<{
5
+ focus: Type.TOptional<Type.TArray<Type.TString>>;
6
+ token_budget: Type.TOptional<Type.TNumber>;
7
+ }>;
8
+ export type RepoMapToolInput = Static<typeof repoMapSchema>;
9
+ export interface RepoMapToolOptions {
10
+ /** Override file gathering (tests). */
11
+ gatherFiles?: (root: string) => string[];
12
+ }
13
+ export declare function createRepoMapToolDefinition(cwd: string, options?: RepoMapToolOptions): ToolDefinition<typeof repoMapSchema, undefined>;
14
+ export declare function createRepoMapTool(cwd: string, options?: RepoMapToolOptions): AgentTool<typeof repoMapSchema>;
15
+ export {};
@@ -0,0 +1,5 @@
1
+ var y=Object.defineProperty;var l=(n,e)=>y(n,"name",{value:e,configurable:!0});import{existsSync as b,readdirSync as w,readFileSync as x}from"node:fs";import{join as m,relative as _}from"node:path";import{Text as d}from"@openadapter/koda-tui";import k from"ignore";import{Type as u}from"typebox";import{buildRepoMap as T,isMappableFile as S}from"../repomap/repomap.js";import{getTextOutput as v,shortenPath as O}from"./render-utils.js";import{wrapToolDefinition as D}from"./tool-definition-wrapper.js";const F=u.Object({focus:u.Optional(u.Array(u.String(),{description:"Optional file paths (relative to the repo root) to bias the map toward \u2014 e.g. the files you're currently working on. The map ranks structurally-related code higher when focus is given."})),token_budget:u.Optional(u.Number({description:"Approximate token budget for the map (default 1024)."}))}),R=["node_modules",".git","dist","build","out","coverage",".next",".nuxt",".cache","vendor","__pycache__",".venv","venv","target",".koda"],h=new Set(R),g=5e3;function E(n){const e=k(),s=m(n,".gitignore");if(b(s))try{e.add(x(s,"utf-8"))}catch{}const r=[],t=l(a=>{if(r.length>=g)return;let i;try{i=w(a,{withFileTypes:!0})}catch{return}for(const o of i){if(r.length>=g)return;if(o.name.startsWith(".")&&o.name!=="."&&h.has(o.name)||h.has(o.name))continue;const c=m(a,o.name),p=_(n,c),f=o.isDirectory()?`${p}/`:p;p&&e.ignores(f)||(o.isDirectory()?t(c):o.isFile()&&S(o.name)&&r.push(c))}},"walk");return t(n),r}l(E,"gatherSourceFiles");function M(n,e){let s=e.fg("toolTitle",e.bold("repo_map"));const r=n?.focus;return r?.length?s+=e.fg("toolOutput"," focus ")+e.fg("accent",r.map(t=>O(t)).join(", ")):s+=e.fg("toolOutput"," (whole repo)"),s}l(M,"formatCall");function j(n,e,s,r){const t=v(n,r).trim();if(!t)return"";const a=t.split(`
2
+ `),i=e.expanded?a.length:16;let c=`
3
+ ${a.slice(0,i).map(f=>s.fg("toolOutput",f)).join(`
4
+ `)}`;const p=a.length-i;return p>0&&(c+=s.fg("muted",`
5
+ \u2026 (${p} more lines)`)),c}l(j,"formatResult");function A(n,e){const s=e?.gatherFiles??E;return{name:"repo_map",label:"repo_map",description:"Get a structural map of the codebase: the most important symbols (functions, classes, methods, types) ranked by how central they are to the project's call/reference graph, with file paths and line numbers. Use this to orient yourself in an unfamiliar repo before grepping, or pass `focus` files to see what's structurally related to what you're working on. Deterministic and always current (parsed live, not embedded).",promptSnippet:"Structural map of the codebase's key symbols, ranked by importance",parameters:F,async execute(r,t,a){if(a?.aborted)throw new Error("Operation aborted");const i=s(n);if(i.length===0)return{content:[{type:"text",text:"Repo map: no source files found to map."}],details:void 0};const o=await T({root:n,files:i,focus:t?.focus,tokenBudget:t?.token_budget&&t.token_budget>0?t.token_budget:1024});if(a?.aborted)throw new Error("Operation aborted");return{content:[{type:"text",text:o}],details:void 0}},renderCall(r,t,a){const i=a.lastComponent??new d("",0,0);return i.setText(M(r,t)),i},renderResult(r,t,a,i){const o=i.lastComponent??new d("",0,0);return o.setText(j(r,t,a,i.showImages)),o}}}l(A,"createRepoMapToolDefinition");function P(n,e){return D(A(n,e))}l(P,"createRepoMapTool");export{P as createRepoMapTool,A as createRepoMapToolDefinition};
@@ -45,6 +45,7 @@ export declare class InteractiveMode {
45
45
  private isInitialized;
46
46
  private onInputCallback?;
47
47
  private pendingUserInputs;
48
+ private _pastedImages;
48
49
  private loadingAnimation;
49
50
  private workingMessage;
50
51
  private workingVisible;
@@ -276,6 +277,7 @@ export declare class InteractiveMode {
276
277
  private showExtensionError;
277
278
  private setupKeyHandlers;
278
279
  private handleClipboardImagePaste;
280
+ private _resolvePastedImages;
279
281
  private setupEditorSubmitHandler;
280
282
  private subscribeToAgent;
281
283
  private handleEvent;