@sixb/agent 0.2.4 → 0.2.6

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 (117) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-prompt.d.ts +13 -3
  3. package/dist/agent-prompt.d.ts.map +1 -1
  4. package/dist/artifacts/layout-check/layout-check.d.ts +21 -24
  5. package/dist/artifacts/layout-check/layout-check.d.ts.map +1 -1
  6. package/dist/artifacts/publish-tool.d.ts.map +1 -1
  7. package/dist/background-commands.d.ts +2 -2
  8. package/dist/context-compaction.d.ts.map +1 -1
  9. package/dist/conversation-messages.d.ts +1 -1
  10. package/dist/conversation-messages.d.ts.map +1 -1
  11. package/dist/index.d.ts +0 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +11082 -9281
  14. package/dist/index.js.map +37 -33
  15. package/dist/login-shell.d.ts +18 -2
  16. package/dist/login-shell.d.ts.map +1 -1
  17. package/dist/model-adapters.d.ts +5 -2
  18. package/dist/model-adapters.d.ts.map +1 -1
  19. package/dist/model-lines.d.ts +1 -0
  20. package/dist/model-lines.d.ts.map +1 -1
  21. package/dist/run-agent-turn.d.ts +3 -14
  22. package/dist/run-agent-turn.d.ts.map +1 -1
  23. package/dist/run-conversation-turn.d.ts.map +1 -1
  24. package/dist/run-environment.d.ts.map +1 -1
  25. package/dist/run-sandbox.d.ts +11 -1
  26. package/dist/run-sandbox.d.ts.map +1 -1
  27. package/dist/run-subagent.d.ts.map +1 -1
  28. package/dist/sandbox-api-context.d.ts.map +1 -1
  29. package/dist/search-script.d.ts +7 -0
  30. package/dist/search-script.d.ts.map +1 -0
  31. package/dist/skills/built-in.d.ts.map +1 -1
  32. package/dist/subagent-tools.d.ts +11 -1
  33. package/dist/subagent-tools.d.ts.map +1 -1
  34. package/dist/tools/bash.d.ts +1 -1
  35. package/dist/tools/bash.d.ts.map +1 -1
  36. package/dist/tools/glob.d.ts +41 -0
  37. package/dist/tools/glob.d.ts.map +1 -0
  38. package/dist/tools/grep.d.ts +64 -0
  39. package/dist/tools/grep.d.ts.map +1 -0
  40. package/dist/tools/model-spec.d.ts.map +1 -1
  41. package/dist/tools/sandbox-search.d.ts +26 -0
  42. package/dist/tools/sandbox-search.d.ts.map +1 -0
  43. package/dist/tools/search/command.d.ts +15 -0
  44. package/dist/tools/search/command.d.ts.map +1 -0
  45. package/dist/tools/search/gitignore.d.ts +28 -0
  46. package/dist/tools/search/gitignore.d.ts.map +1 -0
  47. package/dist/tools/search/glob.d.ts +15 -0
  48. package/dist/tools/search/glob.d.ts.map +1 -0
  49. package/dist/tools/search/main.d.ts +2 -0
  50. package/dist/tools/search/main.d.ts.map +1 -0
  51. package/dist/tools/search/match.d.ts +30 -0
  52. package/dist/tools/search/match.d.ts.map +1 -0
  53. package/dist/tools/search/pattern.d.ts +19 -0
  54. package/dist/tools/search/pattern.d.ts.map +1 -0
  55. package/dist/tools/search/read.d.ts +62 -0
  56. package/dist/tools/search/read.d.ts.map +1 -0
  57. package/dist/tools/search/request.d.ts +80 -0
  58. package/dist/tools/search/request.d.ts.map +1 -0
  59. package/dist/tools/search/search.d.ts +4 -0
  60. package/dist/tools/search/search.d.ts.map +1 -0
  61. package/dist/tools/search/walk.d.ts +43 -0
  62. package/dist/tools/search/walk.d.ts.map +1 -0
  63. package/dist/tools/tool-outputs.d.ts.map +1 -1
  64. package/dist/turn-inbox.d.ts +75 -0
  65. package/dist/turn-inbox.d.ts.map +1 -0
  66. package/package.json +7 -5
  67. package/src/agent-prompt.ts +63 -28
  68. package/src/agent-runtime/preflight.ts +1 -0
  69. package/src/artifacts/layout-check/check.cjs +176 -95
  70. package/src/artifacts/layout-check/layout-check.ts +118 -76
  71. package/src/artifacts/publish-tool.ts +48 -99
  72. package/src/background-commands.ts +8 -6
  73. package/src/context-compaction.ts +1 -0
  74. package/src/conversation-messages.ts +11 -4
  75. package/src/generated/search.mjs +985 -0
  76. package/src/index.ts +0 -1
  77. package/src/login-shell.ts +30 -3
  78. package/src/model-adapters.ts +23 -4
  79. package/src/model-lines.ts +1 -1
  80. package/src/run-agent-turn.ts +85 -129
  81. package/src/run-conversation-turn.ts +15 -6
  82. package/src/run-environment.ts +42 -11
  83. package/src/run-sandbox.ts +60 -1
  84. package/src/run-subagent.ts +9 -2
  85. package/src/sandbox-api-context.ts +10 -1
  86. package/src/search-script-assets.d.ts +5 -0
  87. package/src/search-script.ts +9 -0
  88. package/src/skills/built-in.ts +16 -0
  89. package/src/skills/sixb-artifacts/SKILL.md +7 -7
  90. package/src/skills/sixb-artifacts/canvas.md +3 -2
  91. package/src/skills/sixb-artifacts/document.md +92 -5
  92. package/src/skills/sixb-artifacts/examples/document/service-proposal/design.css +114 -0
  93. package/src/skills/sixb-artifacts/examples/document/service-proposal/document.html +159 -0
  94. package/src/skills/sixb-artifacts/examples/document/service-proposal/images/fieldwise.svg +1 -0
  95. package/src/skills/sixb-artifacts/examples/document/service-proposal/images/harbor-pine.svg +1 -0
  96. package/src/skills/sixb-artifacts/queries.md +2 -1
  97. package/src/subagent-tools.ts +23 -5
  98. package/src/tools/bash.ts +9 -10
  99. package/src/tools/glob.ts +124 -0
  100. package/src/tools/grep.ts +190 -0
  101. package/src/tools/model-spec.ts +4 -0
  102. package/src/tools/sandbox-search.ts +219 -0
  103. package/src/tools/search/command.ts +116 -0
  104. package/src/tools/search/gitignore.ts +101 -0
  105. package/src/tools/search/glob.ts +90 -0
  106. package/src/tools/search/main.ts +9 -0
  107. package/src/tools/search/match.ts +278 -0
  108. package/src/tools/search/pattern.ts +178 -0
  109. package/src/tools/search/read.ts +237 -0
  110. package/src/tools/search/request.ts +101 -0
  111. package/src/tools/search/search.ts +297 -0
  112. package/src/tools/search/walk.ts +145 -0
  113. package/src/tools/tool-outputs.ts +7 -2
  114. package/src/turn-inbox.ts +283 -0
  115. package/dist/artifacts/board-previews.d.ts +0 -41
  116. package/dist/artifacts/board-previews.d.ts.map +0 -1
  117. package/src/artifacts/board-previews.ts +0 -218
@@ -0,0 +1,62 @@
1
+ export type FileText = {
2
+ readonly text: string;
3
+ } | {
4
+ readonly skipped: "binary" | "too_large" | "unreadable";
5
+ };
6
+ /** A read that knows what it will hold before it holds it. */
7
+ export interface PendingRead<R> {
8
+ /** The bytes the read holds once started, until its result is taken. */
9
+ readonly bytes: number;
10
+ /** Never rejects. */
11
+ read(): Promise<R>;
12
+ /** Lets go of a read never started. Never rejects. */
13
+ close(): Promise<void>;
14
+ }
15
+ /**
16
+ * A file opened to be read: one open, and its size from that descriptor. Its text comes from
17
+ * {@link PendingRead.read}, unless it is too large or unreadable, which is known already.
18
+ */
19
+ export declare function openText(path: string, strict: boolean): Promise<PendingRead<FileText>>;
20
+ /**
21
+ * How far reads run ahead of the file searched. Reading is most of a search's time, and mostly
22
+ * waiting: reads in flight overlap that wait. At most {@link READ_AHEAD} files are open, and a read
23
+ * starts only while the reads started hold at most {@link READ_AHEAD_BYTES} of file with it, but
24
+ * for the next file in line, which always starts: one file of 10 MiB past the bound at most. A
25
+ * binary file's bytes are let go once its first bytes show it is one.
26
+ *
27
+ * Memory: the texts read ahead take up to twice their bytes once decoded (a string with one
28
+ * character beyond Latin-1 takes two bytes for each): 52 MiB at worst, plus the file searched and
29
+ * the copies its search makes. 16 MiB reads a source tree as fast as 32 did, and holds half as
30
+ * much over a folder of large files.
31
+ */
32
+ export declare const READ_AHEAD = 32;
33
+ export declare const READ_AHEAD_BYTES: number;
34
+ /**
35
+ * Files read ahead of the one searched, handed back in the order they come, so a search finds the
36
+ * same lines, in the same order, as reading one file at a time. Files are opened as they come,
37
+ * and read as soon as they are open and their bytes fit. A search that stops reads no further than
38
+ * {@link READ_AHEAD} files past where it stopped.
39
+ */
40
+ export declare class ReadAhead<T, R> {
41
+ #private;
42
+ private readonly items;
43
+ /** Never rejects. */
44
+ private readonly open;
45
+ /** What a read that holds nothing once done looks like, a binary file. */
46
+ private readonly holdsNothing;
47
+ constructor(items: Iterator<T>,
48
+ /** Never rejects. */
49
+ open: (item: T) => Promise<PendingRead<R>>,
50
+ /** What a read that holds nothing once done looks like, a binary file. */
51
+ holdsNothing?: (result: R) => boolean);
52
+ next(): Promise<{
53
+ readonly item: T;
54
+ readonly read: R;
55
+ } | undefined>;
56
+ /**
57
+ * Starts no other read, waits for those in flight and closes the files never read: no file
58
+ * stays open past the search.
59
+ */
60
+ stop(): Promise<void>;
61
+ }
62
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/tools/search/read.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAA;CAAE,CAAA;AAE/D,8DAA8D;AAC9D,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,qBAAqB;IACrB,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAA;IAClB,sDAAsD;IACtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAsB5F;AAsED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,KAAK,CAAA;AAC5B,eAAO,MAAM,gBAAgB,QAAmB,CAAA;AAahD;;;;;GAKG;AACH,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC;;IAOvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,qBAAqB;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAJZ,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnC,qBAAqB;IACJ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC3D,0EAA0E;IACzD,YAAY,GAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAqB;IAG/D,IAAI,IAAI,OAAO,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG,SAAS,CAAC;IAiBzE;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAuD5B"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * What `search.mjs` takes and prints: the contract between the `glob` and `grep` tools and the
3
+ * engine the run installs.
4
+ */
5
+ /** How much a search returns, and which files `grep` reads. */
6
+ export declare const SEARCH_LIMITS: {
7
+ readonly files: 100;
8
+ readonly lines: 100;
9
+ readonly linesPerFile: 20;
10
+ readonly lineCharacters: 500;
11
+ /** How much of a cut line shows before its first match. */
12
+ readonly matchLead: 40;
13
+ /**
14
+ * How much of a line `grep` matches. A backtracking regex can take seconds on one long line of a
15
+ * minified file; past this, a match is missed rather than the search stalled.
16
+ */
17
+ readonly matchCharacters: 4000;
18
+ /** What `grep`'s matches may add to its model text, in UTF-8 bytes, before it is truncated. */
19
+ readonly textBytes: number;
20
+ readonly fileBytes: number;
21
+ /** A NUL byte in this many first bytes makes a file binary. */
22
+ readonly binaryProbeBytes: number;
23
+ };
24
+ interface SearchScopeRequest {
25
+ /** Relative to the working directory, or absolute. Default: the working directory. */
26
+ readonly path?: string;
27
+ /**
28
+ * The run's context directory: the second root a search may start from. A search that starts
29
+ * outside it never enters it.
30
+ */
31
+ readonly contextDirectory?: string;
32
+ /** How long the walk may take before it stops with what it found. */
33
+ readonly timeoutMs: number;
34
+ }
35
+ export interface GlobSearchRequest extends SearchScopeRequest {
36
+ readonly tool: "glob";
37
+ readonly pattern: string;
38
+ }
39
+ export interface GrepSearchRequest extends SearchScopeRequest {
40
+ readonly tool: "grep";
41
+ /** A JavaScript regular expression, or the text itself with `literal`. */
42
+ readonly pattern: string;
43
+ /** A `glob` pattern the files searched must match. */
44
+ readonly include?: string;
45
+ readonly literal?: boolean;
46
+ }
47
+ export type SearchRequest = GlobSearchRequest | GrepSearchRequest;
48
+ /**
49
+ * Paths are relative to the working directory when they are under it, absolute otherwise.
50
+ * `incomplete` says the walk stopped at its deadline.
51
+ */
52
+ export interface GlobSearchResult {
53
+ readonly files: string[];
54
+ readonly truncated: boolean;
55
+ readonly incomplete?: true;
56
+ }
57
+ export interface GrepMatch {
58
+ readonly path: string;
59
+ /** One-based. */
60
+ readonly line: number;
61
+ readonly text: string;
62
+ }
63
+ export interface GrepSearchResult {
64
+ readonly matches: GrepMatch[];
65
+ /** How many files the matches are in. */
66
+ readonly files: number;
67
+ /** Matching lines counted past what a file shows, by path. */
68
+ readonly more?: Record<string, number>;
69
+ /** Another file matches past the cap. */
70
+ readonly truncated: boolean;
71
+ readonly incomplete?: true;
72
+ }
73
+ export type SearchErrorCode = "path_missing" | "path_outside" | "path_is_file" | "path_not_searchable" | "invalid_pattern" | "invalid_include" | "file_binary" | "file_too_large";
74
+ /** A search that cannot run as asked: the caller says why in its own words. */
75
+ export declare class SearchError extends Error {
76
+ readonly code: SearchErrorCode;
77
+ constructor(code: SearchErrorCode, message: string);
78
+ }
79
+ export {};
80
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/tools/search/request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,aAAa;;;;;IAKxB,2DAA2D;;IAE3D;;;OAGG;;IAEH,+FAA+F;;;IAG/F,+DAA+D;;CAEvD,CAAA;AAEV,UAAU,kBAAkB;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM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AE,OAAO,CAAA;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;CAC3B;AAED,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,aAAa,GACb,gBAAgB,CAAA;AAEpB,+EAA+E;AAC/E,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,IAAI,EAAE,eAAe;gBAArB,IAAI,EAAE,eAAe,EAC9B,OAAO,EAAE,MAAM;CAKlB"}
@@ -0,0 +1,4 @@
1
+ import { type GlobSearchRequest, type GlobSearchResult, type GrepSearchRequest, type GrepSearchResult } from "./request";
2
+ export declare function globFiles(request: GlobSearchRequest, workingDirectory: string): GlobSearchResult;
3
+ export declare function grepFiles(request: GrepSearchRequest, workingDirectory: string): Promise<GrepSearchResult>;
4
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/tools/search/search.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAKtB,MAAM,WAAW,CAAA;AAGlB,wBAAgB,SAAS,CAAC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,GAAG,gBAAgB,CAmBhG;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,iBAAiB,EAC1B,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAmG3B"}
@@ -0,0 +1,43 @@
1
+ import { type IgnoreFile } from "./gitignore";
2
+ export interface WalkOptions {
3
+ /** The folder to walk: a real, absolute path. */
4
+ readonly root: string;
5
+ /** The `.gitignore` files of the folders above the root that apply, outermost first. */
6
+ readonly ignoreFiles: readonly IgnoreFile[];
7
+ /** Enter folders and list files whose name starts with `.`. */
8
+ readonly hidden: boolean;
9
+ readonly nodeModules: boolean;
10
+ /** Real, absolute paths of folders never entered: the run's context directory. */
11
+ readonly skipFolders: ReadonlySet<string>;
12
+ /** Whether a folder, relative to the root, may hold what the search looks for. */
13
+ readonly mayContain?: (relativeFolder: string) => boolean;
14
+ /** The time, in epoch milliseconds, at which the walk stops. */
15
+ readonly deadline: number;
16
+ }
17
+ export interface WalkedFile {
18
+ readonly path: string;
19
+ /** From the root, with `/`. */
20
+ readonly relative: string;
21
+ /** A link to a file: listed, but its target may be anywhere. */
22
+ readonly symlink: boolean;
23
+ }
24
+ /**
25
+ * The files under a folder, in byte order of their paths, so that the first results of a capped
26
+ * search are the same on every run. `.git`, hidden entries and `node_modules` unless asked for,
27
+ * what `.gitignore` files exclude, and unreadable entries are skipped. Links to folders are not
28
+ * followed. Past its deadline, the walk stops and says it is {@link incomplete}.
29
+ */
30
+ export declare class FileWalk {
31
+ #private;
32
+ private readonly options;
33
+ constructor(options: WalkOptions);
34
+ get incomplete(): boolean;
35
+ files(): Generator<WalkedFile>;
36
+ }
37
+ /**
38
+ * A folder's `.gitignore`, or another ignore file applying from it, when it is a regular file it
39
+ * can read. A link is not followed, as git does not, and a device or a FIFO is never opened.
40
+ */
41
+ export declare function readIgnoreFile(folder: string, name?: string): IgnoreFile | undefined;
42
+ export declare function childPath(folder: string, name: string): string;
43
+ //# sourceMappingURL=walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/tools/search/walk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAA6B,MAAM,aAAa,CAAA;AAExE,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAA;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC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G,SAAS,EAAE;IAI9C,8EAA8E;IAC9E,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIzD,OAAO,CAAC,MAAM;IA2Cd;;;;OAIG;IACG,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAClF,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC;YAMJ,IAAI;YAeJ,KAAK;CAkCpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GAAG,iBAAiB,EAAE,CAejG;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAA;IAC5C,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiChB;AAoCD,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE"}
@@ -0,0 +1,75 @@
1
+ import type { AgentMessagePart, AgentStepRequestSize } from "@sixb/core";
2
+ import { type AgentRunSession, type PausableModelLoopResult } from "@sixb/core/internal/agents";
3
+ import type { ModelAssistantPart, ModelMessage, ModelStep } from "@sixb/core/models";
4
+ import type { AgentInboxItemRecord, AgentMessageRecord, AppendAgentMessageInput, ConversationAgentRunRecord, Principal } from "@sixb/core/storage";
5
+ import { type SentSettings } from "./agent-prompt";
6
+ import { type ConversationReaders } from "./message-authors";
7
+ import { type AgentToolOutputFileOf } from "./model-adapters";
8
+ /** A steer the turn read at one of its step boundaries: which step, and what it read. */
9
+ export interface TurnInboxDelivery {
10
+ /** The step the messages came after: its own count of the steps the turn completed. */
11
+ readonly afterSteps: number;
12
+ readonly items: readonly AgentInboxItemRecord[];
13
+ }
14
+ /** What a steer's message is projected from: the thread as the turn started, and who reads it. */
15
+ interface TurnInboxContext {
16
+ readonly retainedMessages: readonly AgentMessageRecord[];
17
+ readonly conversation?: ConversationReaders;
18
+ readonly project: SentSettings;
19
+ }
20
+ /**
21
+ * A turn's mid-run steers, drained from its session's inbox at step boundaries.
22
+ *
23
+ * Every item a turn reads is claimed by its run and its step, so a step that reads twice reads
24
+ * once, and a turn that never writes one releases it (see AgentRunSession.finish). The messages
25
+ * here are what the model read: its history plus the steer, projected the way the next turn's
26
+ * replay of `agent_messages` projects it, so both send the same bytes.
27
+ */
28
+ export declare class TurnInbox {
29
+ #private;
30
+ private readonly session;
31
+ constructor(session: AgentRunSession, context: TurnInboxContext);
32
+ /** What the turn read, in order. */
33
+ get deliveries(): readonly TurnInboxDelivery[];
34
+ /**
35
+ * The messages the model reads after `afterSteps` steps; none when nothing waits. `afterAnswer`
36
+ * marks a read that came as the model answered, which the next request follows with one more
37
+ * step.
38
+ */
39
+ take(afterSteps: number, options?: {
40
+ readonly afterAnswer?: boolean;
41
+ }): Promise<readonly ModelMessage[]>;
42
+ }
43
+ /**
44
+ * Slice the steps a turn completed, or the part of one it did not, around the steers it read, as
45
+ * `agent_messages` rows: one assistant message up to each delivery, the steer as its own user
46
+ * message, then the rest. A steer no step followed — the turn stopped before answering it — is
47
+ * left out, so finishing without its message releases it back to the thread's inbox.
48
+ */
49
+ export declare function turnWorkMessages(input: {
50
+ readonly steps: readonly ModelStep[];
51
+ /** What an aborted step streamed: the one step `steps` does not hold whole. */
52
+ readonly partialContent?: readonly ModelAssistantPart[];
53
+ readonly aborted?: boolean;
54
+ readonly run: ConversationAgentRunRecord;
55
+ readonly deliveries: readonly TurnInboxDelivery[];
56
+ /** The first step whose request the context guard reduced: it and those after it are marked. */
57
+ readonly reducedFromStep?: number;
58
+ readonly stepRequests: readonly (AgentStepRequestSize | undefined)[];
59
+ readonly outputFileOf?: AgentToolOutputFileOf;
60
+ readonly authorPrincipal?: Principal;
61
+ }): readonly AppendAgentMessageInput[];
62
+ /** The rows a turn finishes with, for the model loop it just ran. */
63
+ export declare function turnResultMessages(result: PausableModelLoopResult, input: Omit<Parameters<typeof turnWorkMessages>[0], "steps" | "partialContent" | "aborted">): readonly AppendAgentMessageInput[];
64
+ /**
65
+ * Mark each step from `fromStep` on as answering a request the turn reduced, for the next turn's
66
+ * estimate not to go by what those calls read.
67
+ */
68
+ export declare function markReducedSteps(parts: readonly AgentMessagePart[], fromStep: number | undefined): readonly AgentMessagePart[];
69
+ /**
70
+ * Record on each step-start what its request carried, by step: the next turn's context meter
71
+ * reads the system prompt and tools the latest one sent.
72
+ */
73
+ export declare function recordStepRequests(parts: readonly AgentMessagePart[], requests: readonly (AgentStepRequestSize | undefined)[]): readonly AgentMessagePart[];
74
+ export {};
75
+ //# sourceMappingURL=turn-inbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-inbox.d.ts","sourceRoot":"","sources":["../src/turn-inbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,E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,MAAM,CAAA;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,oBAAoB,GAAG,SAAS,CAAC,EAAE,CAAA;IACpE,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAA;IAC7C,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,CAAA;CACrC,GAAG,SAAS,uBAAuB,EAAE,CAqDrC;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAAC,GAC1F,SAAS,uBAAuB,EAAE,CASpC;AA2BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAClC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,SAAS,gBAAgB,EAAE,CAU7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAClC,QAAQ,EAAE,SAAS,CAAC,oBAAoB,GAAG,SAAS,CAAC,EAAE,GACtD,SAAS,gBAAgB,EAAE,CAS7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/agent",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "The Sixb agent harness: one loop, prompt and tools for every runner",
5
5
  "keywords": [
6
6
  "sixb",
@@ -29,18 +29,20 @@
29
29
  },
30
30
  "scripts": {
31
31
  "build": "bun ../../scripts/build-package.ts",
32
+ "generate:search-script": "bun ./scripts/generate-search-script.ts",
33
+ "check:search-script": "bun ./scripts/generate-search-script.ts --check",
32
34
  "typecheck": "tsc --noEmit",
33
35
  "test": "bun test",
34
36
  "test:e2e": "bun ../../scripts/ci-guard.ts --stall 120 --max 300 bun test ./tests/layout-check.e2e.ts",
35
37
  "prepack": "bun run build"
36
38
  },
37
39
  "peerDependencies": {
38
- "@sixb/core": "0.2.4"
40
+ "@sixb/core": "0.2.6"
39
41
  },
40
42
  "devDependencies": {
41
- "@sixb/core": "0.2.4",
43
+ "@sixb/core": "0.2.6",
42
44
  "@sixb/sandboxes-local": "0.2.0",
43
- "@sixb/vercel-ai-gateway": "0.2.4",
45
+ "@sixb/vercel-ai-gateway": "0.2.6",
44
46
  "@types/bun": "latest",
45
47
  "@types/hast": "^3.0.5",
46
48
  "@types/mdast": "^4.0.4",
@@ -61,7 +63,7 @@
61
63
  "LICENSE"
62
64
  ],
63
65
  "dependencies": {
64
- "@sixb/cli-core": "^0.2.3",
66
+ "@sixb/cli-core": "^0.2.4",
65
67
  "hast-util-from-parse5": "^8.0.4",
66
68
  "hast-util-to-mdast": "^10.1.2",
67
69
  "mdast-util-gfm": "^3.1.0",
@@ -3,10 +3,10 @@ import { renderInstanceHelp } from "@sixb/cli-core"
3
3
  import type { AgentSkillDefinition, AgentSystemPromptPartName } from "@sixb/core"
4
4
  import type { AgentSystemPromptSize, SandboxModel } from "@sixb/core/internal/agents"
5
5
  import type { OntologyDocsIndexEntry } from "@sixb/core/internal/ontology"
6
- import type { ModelMessage } from "@sixb/core/models"
6
+ import type { LanguageModel, ModelMessage } from "@sixb/core/models"
7
7
  import type { SubagentRunFile } from "@sixb/core/storage"
8
8
  import { CHILD_FILES_DIRECTORY, formatBytes, SANDBOX_ATTACHMENT_LIMITS } from "./attachments"
9
- import { renderModelLine } from "./model-lines"
9
+ import { oneLine, renderModelLine } from "./model-lines"
10
10
  import type { AgentRequester } from "./requester"
11
11
 
12
12
  export type AgentExecutionMode = "conversation" | "subagent" | "workflow-task"
@@ -98,8 +98,6 @@ export interface RenderAgentSystemPromptInput {
98
98
  /** Ontology reference files to list; omitted, the prompt does not mention them. */
99
99
  readonly ontologyIndex?: readonly OntologyDocsIndexEntry[]
100
100
  readonly sandboxResetAt?: string
101
- /** When the conversation's turns moved to this workspace, from a computer or another folder. */
102
- readonly workspaceMovedAt?: string
103
101
  readonly workspace?: AgentWorkspacePromptContext
104
102
  readonly facts?: AgentRuntimeFacts
105
103
  /**
@@ -109,9 +107,14 @@ export interface RenderAgentSystemPromptInput {
109
107
  readonly conversation?: string
110
108
  /** Models the sandbox CLI can call; omitted, the prompt does not mention them. */
111
109
  readonly sandboxModels?: readonly SandboxModel[]
110
+ /** The model the run calls, which the prompt names; omitted, it names none. */
111
+ readonly runningModel?: RunningModel
112
112
  readonly memory?: AgentMemoryPromptContext
113
113
  }
114
114
 
115
+ /** What the prompt reads of the run's model: its identity, and its name when it has one. */
116
+ type RunningModel = Pick<LanguageModel, "providerId" | "modelId" | "definition">
117
+
115
118
  /** The Agent's memory as the prompt shows it. */
116
119
  export interface AgentMemoryPromptContext {
117
120
  /** Others read the conversation: the project's memory alone is loaded, whoever sends the turn. */
@@ -214,7 +217,8 @@ function renderAgentSystemPromptSections(
214
217
  input.contextDirectory,
215
218
  input.skills,
216
219
  input.ontologyIndex,
217
- input.sandboxModels
220
+ input.sandboxModels,
221
+ input.runningModel
218
222
  )
219
223
  const memory = input.memory && renderMemory(input.memory, input.mode, input.contextDirectory)
220
224
  const system = (text: string | undefined): PromptSection[] =>
@@ -233,14 +237,7 @@ function renderAgentSystemPromptSections(
233
237
  ]),
234
238
  promptSectionParts(
235
239
  "sandbox_state",
236
- system(
237
- [
238
- input.workspaceMovedAt && renderWorkspaceMove(input.workspaceMovedAt),
239
- input.sandboxResetAt && renderSandboxReset(input.sandboxResetAt, input.mode),
240
- ]
241
- .filter(Boolean)
242
- .join("\n\n")
243
- )
240
+ system(input.sandboxResetAt && renderSandboxReset(input.sandboxResetAt, input.mode))
244
241
  ),
245
242
  promptSectionParts(
246
243
  "agent_instructions",
@@ -308,9 +305,18 @@ function promptSectionParts(
308
305
  return [{ part: tagPart, text: `<${tag}>\n` }, ...body, { part: tagPart, text: `\n</${tag}>` }]
309
306
  }
310
307
 
311
- /** What a turn is told once its conversation moved here: from a computer, or another folder. */
312
- function renderWorkspaceMove(movedAt: string): string {
313
- return `This conversation moved to this workspace at ${movedAt}. The files and paths that earlier tool calls used were in the workspace it moved from and are not here. Conversation history and attachments remain available. Inspect this workspace before relying on earlier filesystem results. Whenever you report that this workspace is empty or that a file is missing, add that files from before the move stayed in the workspace it moved from.`
308
+ /**
309
+ * Marks a user message sent after the conversation moved to another workspace (between the cloud
310
+ * and a computer, or between folders). It closes the message rather than the system prompt, so a
311
+ * thread that returns to a workspace keeps that workspace's prompt, and the cached prefix that
312
+ * follows it, byte for byte.
313
+ */
314
+ export function renderWorkspaceMovedTag(): string {
315
+ return [
316
+ "<sixb_workspace_moved>",
317
+ "This conversation moved to a different workspace before this message. Files, paths and local processes from before this message stayed in the workspace it moved from and are not here; conversation history, artifacts and attachments remain available. Inspect the current workspace before relying on earlier filesystem results, and when reporting a missing file from before this move, note that it stayed in the previous workspace.",
318
+ "</sixb_workspace_moved>",
319
+ ].join("\n")
314
320
  }
315
321
 
316
322
  /** What a run is told once its thread's workspace was lost and created again. */
@@ -340,7 +346,8 @@ function renderRuntimeContext(
340
346
  contextDirectory: string,
341
347
  skills: readonly AgentSkillDefinition[],
342
348
  ontologyIndex: readonly OntologyDocsIndexEntry[] = [],
343
- sandboxModels: readonly SandboxModel[] = []
349
+ sandboxModels: readonly SandboxModel[] = [],
350
+ runningModel?: RunningModel
344
351
  ): { readonly base: string[]; readonly skills: string[]; readonly ontology: string[] } {
345
352
  const skillCatalog =
346
353
  skills.length === 0
@@ -398,9 +405,10 @@ function renderRuntimeContext(
398
405
  'When an Action id is provided, inspect it directly with `sixb actions get <action-id>`; its `inputSchema` is the exact JSON shape accepted by the Action. An object-reference parameter is an object such as `{"objectTypeId":"Type","primaryId":"opaque:id"}`, never a bare id.',
399
406
  "Send Action params as one JSON object through standard input with `sixb actions request <action-id> --file -`; it runs the Action and prints the finished run, with its status and any error. Never inspect the environment to infer identifiers.",
400
407
  "Do not use ontology or Action listings, broad object inspection, or environment inspection when exact references and commands are already known. Use `--run-id` only for a request-specific idempotency key.",
401
- ...renderModelCommands(sandboxModels),
408
+ ...renderModelCommands(sandboxModels, runningModel),
402
409
  ...fileContext,
403
410
  "With read, use relative paths from this prompt or sandboxPath values.",
411
+ "Find files with glob and text with grep before you read them. Read a file before you change it, and change files with edit and write rather than shell commands; a memory save stays one bash command that edits and saves.",
404
412
  ]
405
413
  return { base, skills: skillCatalog, ontology: ontologyCatalog }
406
414
  }
@@ -415,15 +423,24 @@ const MODEL_COMMANDS: Readonly<Record<(typeof MEDIA_MODEL_KINDS)[number], string
415
423
  }
416
424
 
417
425
  /**
418
- * The commands that call the project's models, each followed by its models with what each is for,
419
- * so the agent picks one without listing them. Each call is billed.
426
+ * The model the run is on, then the commands that call the project's models, each followed by its
427
+ * models with what each is for, so the agent picks one without listing them. Each call is billed.
428
+ * The first line stays when there are no commands: a project's only model still names itself.
420
429
  */
421
- function renderModelCommands(models: readonly SandboxModel[]): string[] {
422
- const language = renderLanguageModelCommand(models.filter((model) => model.kind === "language"))
430
+ function renderModelCommands(
431
+ models: readonly SandboxModel[],
432
+ runningModel?: RunningModel
433
+ ): string[] {
434
+ const language = renderLanguageModelCommand(
435
+ models.filter((model) => model.kind === "language"),
436
+ runningModel
437
+ )
423
438
  const media = renderMediaModelCommands(models.filter((model) => model.kind !== "language"))
424
- if (language.length === 0 && media.length === 0) return []
439
+ const running = runningModel ? [`You are running on ${formatRunningModel(runningModel)}.`] : []
440
+ if (language.length === 0 && media.length === 0) return running
425
441
 
426
442
  return [
443
+ ...running,
427
444
  "The project's models are yours to call through `sixb models`.",
428
445
  ...language,
429
446
  ...media,
@@ -431,23 +448,41 @@ function renderModelCommands(models: readonly SandboxModel[]): string[] {
431
448
  ]
432
449
  }
433
450
 
451
+ /** The run's model as the prompt names it, such as `DeepSeek V4.1 Flash (azure/deepseek-v4.1)`. */
452
+ function formatRunningModel(model: RunningModel): string {
453
+ const reference = `${model.providerId}/${model.modelId}`
454
+ const { name } = model.definition
455
+
456
+ return name ? `${oneLine(name)} (${reference})` : reference
457
+ }
458
+
434
459
  /**
435
460
  * Another model's answer, without a child agent: one generation from the prompt alone. Listed only
436
- * when the project has several language models, since otherwise there is no other to ask.
461
+ * when the project has several language models, since otherwise there is no other to ask. The
462
+ * run's own model is marked `(you)`, so the agent tells itself apart from the others.
437
463
  */
438
- function renderLanguageModelCommand(models: readonly SandboxModel[]): string[] {
464
+ function renderLanguageModelCommand(
465
+ models: readonly SandboxModel[],
466
+ runningModel?: RunningModel
467
+ ): string[] {
439
468
  if (models.length < 2) return []
440
469
 
441
470
  const tiers = [...new Set(models.flatMap((model) => (model.tier ? [model.tier] : [])))]
442
471
  const reference = tiers.length > 0 ? "<tier or model>" : "<model>"
443
- const lines = models.map((model) =>
444
- renderModelLine({
472
+ const lines = models.map((model) => {
473
+ const isRunning =
474
+ runningModel !== undefined &&
475
+ model.provider === runningModel.providerId &&
476
+ model.modelId === runningModel.modelId
477
+
478
+ return renderModelLine({
445
479
  ...(model.tier === undefined ? {} : { tier: model.tier }),
446
480
  reference: cliModelReference(model, models),
447
481
  ...(model.name === undefined ? {} : { name: model.name }),
482
+ ...(isRunning ? { details: "(you)" } : {}),
448
483
  ...(model.description === undefined ? {} : { description: model.description }),
449
484
  })
450
- )
485
+ })
451
486
 
452
487
  return [
453
488
  `Ask another model for a second opinion or a quick generation: \`sixb models text "<prompt>" --model ${reference}\`, or \`--file -\` to send a long prompt on standard input. It answers once from the prompt alone, without the project's data or tools, so put everything it needs in the prompt.`,
@@ -269,6 +269,7 @@ const LOCAL_BEHAVIOR_PROBE = `set -u
269
269
  [ "$(command -v sixb)" = "$SIXB_BIN_DIR/sixb" ] || exit 21
270
270
  [ -x "$SIXB_BIN_DIR/sixb" ] || exit 22
271
271
  [ -r "$SIXB_CONTEXT_DIR/lib/sixb.mjs" ] || exit 22
272
+ [ -r "$SIXB_CONTEXT_DIR/lib/search.mjs" ] || exit 22
272
273
  realpath_bin="$(command -v realpath)" || exit 23
273
274
  tail_bin="$(command -v tail)" || exit 23
274
275
  head_bin="$(command -v head)" || exit 23