thinkwell 0.5.5 → 0.5.7
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/agent.d.ts.map +1 -1
- package/dist/agent.js +232 -278
- package/dist/agent.js.map +1 -1
- package/dist/build.js +44 -98
- package/dist/cli/build.js +92 -227
- package/dist/cli/bundle.js +570 -1136
- package/dist/cli/check.js +125 -214
- package/dist/cli/commands.js +63 -177
- package/dist/cli/compiler-host.js +81 -190
- package/dist/cli/dependency-check.js +125 -269
- package/dist/cli/dependency-errors.js +12 -84
- package/dist/cli/fmt.js +1 -13
- package/dist/cli/init-command.js +21 -68
- package/dist/cli/init.js +90 -220
- package/dist/cli/loader.js +95 -361
- package/dist/cli/new-command.js +25 -73
- package/dist/cli/package-manager.js +50 -117
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +91 -245
- package/dist/cli/schema.js.map +1 -1
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +6 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +5 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -5
- package/dist/schema.js +3 -36
- package/dist/session.js +50 -82
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +287 -368
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +1 -0
- package/dist/thought-event.d.ts.map +1 -1
- package/dist/thought-event.js +0 -1
- package/dist/thought-stream.js +60 -96
- package/dist-pkg/acp.cjs +13386 -1876
- package/dist-pkg/cli-build.cjs +264 -446
- package/dist-pkg/cli-bundle.cjs +433 -818
- package/dist-pkg/cli-check.cjs +302 -499
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +91 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +927 -1846
- package/package.json +9 -7
package/dist/cli/workspace.js
CHANGED
|
@@ -1,248 +1,114 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workspace detection for `thinkwell check`.
|
|
3
|
-
*
|
|
4
|
-
* Detects pnpm workspaces (pnpm-workspace.yaml) and npm workspaces
|
|
5
|
-
* (package.json "workspaces"), enumerates member packages, and resolves
|
|
6
|
-
* package names with short-name fallback for scoped packages.
|
|
7
|
-
*/
|
|
8
1
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
9
2
|
import { join, resolve } from "node:path";
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// pnpm-workspace.yaml parsing
|
|
12
|
-
// ============================================================================
|
|
13
|
-
/**
|
|
14
|
-
* Parse the `packages` array from a pnpm-workspace.yaml file.
|
|
15
|
-
*
|
|
16
|
-
* Handles the simple list format used by pnpm:
|
|
17
|
-
* ```yaml
|
|
18
|
-
* packages:
|
|
19
|
-
* - "packages/*"
|
|
20
|
-
* - "examples"
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* This is intentionally minimal — it only extracts the `packages` array
|
|
24
|
-
* entries without pulling in a full YAML parser dependency.
|
|
25
|
-
*/
|
|
26
3
|
export function parsePnpmWorkspaceYaml(content) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
// A non-indented, non-empty line that isn't a list item ends the block
|
|
38
|
-
if (inPackages && trimmed.length > 0 && !trimmed.startsWith("-") && !line.startsWith(" ") && !line.startsWith("\t")) {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if (inPackages && trimmed.startsWith("-")) {
|
|
42
|
-
// Strip leading "- ", then strip optional quotes
|
|
43
|
-
const value = trimmed.slice(1).trim().replace(/^["']|["']$/g, "");
|
|
44
|
-
if (value.length > 0) {
|
|
45
|
-
patterns.push(value);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
4
|
+
const patterns = [], lines = content.split(`
|
|
5
|
+
`);
|
|
6
|
+
let inPackages = !1;
|
|
7
|
+
for (const line of lines) {
|
|
8
|
+
const trimmed = line.trim();
|
|
9
|
+
if (/^packages\s*:/.test(trimmed)) {
|
|
10
|
+
inPackages = !0;
|
|
11
|
+
continue;
|
|
48
12
|
}
|
|
49
|
-
|
|
13
|
+
if (inPackages && trimmed.length > 0 && !trimmed.startsWith("-") && !line.startsWith(" ") && !line.startsWith(" "))
|
|
14
|
+
break;
|
|
15
|
+
if (inPackages && trimmed.startsWith("-")) {
|
|
16
|
+
const value = trimmed.slice(1).trim().replace(/^["']|["']$/g, "");
|
|
17
|
+
value.length > 0 && patterns.push(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return patterns;
|
|
50
21
|
}
|
|
51
|
-
// ============================================================================
|
|
52
|
-
// Glob expansion
|
|
53
|
-
// ============================================================================
|
|
54
|
-
/**
|
|
55
|
-
* Expand workspace glob patterns into concrete directory paths.
|
|
56
|
-
*
|
|
57
|
-
* Supports the common patterns used by pnpm and npm workspaces:
|
|
58
|
-
* - `packages/*` — all immediate subdirectories of `packages/`
|
|
59
|
-
* - `examples` — a single directory
|
|
60
|
-
* - `apps/**` — recursively find directories (not commonly used but supported)
|
|
61
|
-
*
|
|
62
|
-
* Only returns directories that actually exist.
|
|
63
|
-
*/
|
|
64
22
|
export function expandWorkspaceGlobs(rootDir, patterns) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const fullPath = suffix
|
|
85
|
-
? resolve(baseDir, entry, suffix)
|
|
86
|
-
: resolve(baseDir, entry);
|
|
87
|
-
if (existsSync(fullPath) && isDirectory(fullPath)) {
|
|
88
|
-
dirs.push(fullPath);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (globPart === "**") {
|
|
93
|
-
// Recursive wildcard: find all directories recursively
|
|
94
|
-
collectDirectories(baseDir, suffix, dirs);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// Literal path
|
|
99
|
-
const fullPath = resolve(rootDir, pattern);
|
|
100
|
-
if (existsSync(fullPath) && isDirectory(fullPath)) {
|
|
101
|
-
dirs.push(fullPath);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return dirs;
|
|
23
|
+
const dirs = [];
|
|
24
|
+
for (const pattern of patterns)
|
|
25
|
+
if (!pattern.startsWith("!"))
|
|
26
|
+
if (pattern.includes("*")) {
|
|
27
|
+
const parts = pattern.split("/"), globIndex = parts.findIndex((p) => p.includes("*")), prefix = parts.slice(0, globIndex).join("/"), globPart = parts[globIndex], suffix = parts.slice(globIndex + 1).join("/"), baseDir = resolve(rootDir, prefix);
|
|
28
|
+
if (!existsSync(baseDir))
|
|
29
|
+
continue;
|
|
30
|
+
if (globPart === "*") {
|
|
31
|
+
const entries = readdirSync(baseDir);
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
const fullPath = suffix ? resolve(baseDir, entry, suffix) : resolve(baseDir, entry);
|
|
34
|
+
existsSync(fullPath) && isDirectory(fullPath) && dirs.push(fullPath);
|
|
35
|
+
}
|
|
36
|
+
} else globPart === "**" && collectDirectories(baseDir, suffix, dirs);
|
|
37
|
+
} else {
|
|
38
|
+
const fullPath = resolve(rootDir, pattern);
|
|
39
|
+
existsSync(fullPath) && isDirectory(fullPath) && dirs.push(fullPath);
|
|
40
|
+
}
|
|
41
|
+
return dirs;
|
|
106
42
|
}
|
|
107
43
|
function isDirectory(path) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
44
|
+
try {
|
|
45
|
+
return statSync(path).isDirectory();
|
|
46
|
+
} catch {
|
|
47
|
+
return !1;
|
|
48
|
+
}
|
|
114
49
|
}
|
|
115
50
|
function collectDirectories(baseDir, suffix, result) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
result.push(candidate);
|
|
132
|
-
}
|
|
133
|
-
// Recurse
|
|
134
|
-
collectDirectories(fullPath, suffix, result);
|
|
135
|
-
}
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = readdirSync(baseDir);
|
|
54
|
+
} catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (entry.startsWith(".") || entry === "node_modules")
|
|
59
|
+
continue;
|
|
60
|
+
const fullPath = resolve(baseDir, entry);
|
|
61
|
+
if (!isDirectory(fullPath))
|
|
62
|
+
continue;
|
|
63
|
+
const candidate = suffix ? resolve(fullPath, suffix) : fullPath;
|
|
64
|
+
existsSync(candidate) && isDirectory(candidate) && result.push(candidate), collectDirectories(fullPath, suffix, result);
|
|
65
|
+
}
|
|
136
66
|
}
|
|
137
|
-
// ============================================================================
|
|
138
|
-
// Package metadata
|
|
139
|
-
// ============================================================================
|
|
140
|
-
/**
|
|
141
|
-
* Read workspace member metadata from a package directory.
|
|
142
|
-
* Returns undefined if the directory has no package.json or no "name" field.
|
|
143
|
-
*/
|
|
144
67
|
function readMember(dir) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return undefined;
|
|
68
|
+
const pkgPath = join(dir, "package.json");
|
|
69
|
+
if (existsSync(pkgPath))
|
|
148
70
|
try {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
return undefined;
|
|
71
|
+
const content = readFileSync(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
72
|
+
return !pkg.name || typeof pkg.name != "string" ? void 0 : {
|
|
73
|
+
name: pkg.name,
|
|
74
|
+
dir,
|
|
75
|
+
hasTsConfig: existsSync(join(dir, "tsconfig.json"))
|
|
76
|
+
};
|
|
77
|
+
} catch {
|
|
78
|
+
return;
|
|
161
79
|
}
|
|
162
80
|
}
|
|
163
|
-
// ============================================================================
|
|
164
|
-
// Workspace detection
|
|
165
|
-
// ============================================================================
|
|
166
|
-
/**
|
|
167
|
-
* Detect a workspace in the given directory.
|
|
168
|
-
*
|
|
169
|
-
* Detection priority: pnpm-workspace.yaml takes precedence over
|
|
170
|
-
* package.json "workspaces" (pnpm ignores the npm workspaces field).
|
|
171
|
-
*
|
|
172
|
-
* Returns undefined if no workspace is detected (single-package project).
|
|
173
|
-
*/
|
|
174
81
|
export function detectWorkspace(rootDir) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (patterns.length > 0) {
|
|
182
|
-
const dirs = expandWorkspaceGlobs(absRoot, patterns);
|
|
183
|
-
const members = dirs
|
|
184
|
-
.map(readMember)
|
|
185
|
-
.filter((m) => m !== undefined);
|
|
186
|
-
return { rootDir: absRoot, type: "pnpm", members };
|
|
187
|
-
}
|
|
82
|
+
const absRoot = resolve(rootDir), pnpmPath = join(absRoot, "pnpm-workspace.yaml");
|
|
83
|
+
if (existsSync(pnpmPath)) {
|
|
84
|
+
const content = readFileSync(pnpmPath, "utf-8"), patterns = parsePnpmWorkspaceYaml(content);
|
|
85
|
+
if (patterns.length > 0) {
|
|
86
|
+
const members = expandWorkspaceGlobs(absRoot, patterns).map(readMember).filter((m) => m !== void 0);
|
|
87
|
+
return { rootDir: absRoot, type: "pnpm", members };
|
|
188
88
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const members = dirs
|
|
200
|
-
.map(readMember)
|
|
201
|
-
.filter((m) => m !== undefined);
|
|
202
|
-
return { rootDir: absRoot, type: "npm", members };
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
catch {
|
|
207
|
-
// Invalid package.json — treat as no workspace
|
|
89
|
+
}
|
|
90
|
+
const pkgPath = join(absRoot, "package.json");
|
|
91
|
+
if (existsSync(pkgPath))
|
|
92
|
+
try {
|
|
93
|
+
const content = readFileSync(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
94
|
+
if (Array.isArray(pkg.workspaces)) {
|
|
95
|
+
const patterns = pkg.workspaces.filter((p) => typeof p == "string");
|
|
96
|
+
if (patterns.length > 0) {
|
|
97
|
+
const members = expandWorkspaceGlobs(absRoot, patterns).map(readMember).filter((m) => m !== void 0);
|
|
98
|
+
return { rootDir: absRoot, type: "npm", members };
|
|
208
99
|
}
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
209
102
|
}
|
|
210
|
-
return undefined;
|
|
211
103
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Resolve a package name (full or short) against workspace members.
|
|
214
|
-
*
|
|
215
|
-
* Resolution order:
|
|
216
|
-
* 1. Exact match on full package name (e.g., "@thinkwell/acp")
|
|
217
|
-
* 2. Short-name fallback: match last segment of scoped names (e.g., "acp" → "@thinkwell/acp")
|
|
218
|
-
* 3. Ambiguity detection if short name matches multiple packages
|
|
219
|
-
*/
|
|
220
104
|
export function resolvePackageName(name, members) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const lastSegment = m.name.includes("/")
|
|
231
|
-
? m.name.split("/").pop()
|
|
232
|
-
: m.name;
|
|
233
|
-
return lastSegment === name;
|
|
234
|
-
});
|
|
235
|
-
if (shortMatches.length === 1) {
|
|
236
|
-
return { kind: "found", member: shortMatches[0] };
|
|
237
|
-
}
|
|
238
|
-
if (shortMatches.length > 1) {
|
|
239
|
-
return { kind: "ambiguous", name, matches: shortMatches };
|
|
240
|
-
}
|
|
241
|
-
// 3. Not found
|
|
242
|
-
return {
|
|
243
|
-
kind: "not-found",
|
|
244
|
-
name,
|
|
245
|
-
available: members.map((m) => m.name),
|
|
246
|
-
};
|
|
105
|
+
const exact = members.find((m) => m.name === name);
|
|
106
|
+
if (exact)
|
|
107
|
+
return { kind: "found", member: exact };
|
|
108
|
+
const shortMatches = members.filter((m) => (m.name.includes("/") ? m.name.split("/").pop() : m.name) === name);
|
|
109
|
+
return shortMatches.length === 1 ? { kind: "found", member: shortMatches[0] } : shortMatches.length > 1 ? { kind: "ambiguous", name, matches: shortMatches } : {
|
|
110
|
+
kind: "not-found",
|
|
111
|
+
name,
|
|
112
|
+
available: members.map((m) => m.name)
|
|
113
|
+
};
|
|
247
114
|
}
|
|
248
|
-
//# sourceMappingURL=workspace.js.map
|
package/dist/connectors/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export const CLAUDE_CODE = "npx -y @zed-industries/claude-code-acp";
|
|
2
|
-
export const CODEX = "npx -y @zed-industries/codex-acp";
|
|
3
|
-
export const GEMINI = "npx -y @google/gemini-cli --experimental-acp";
|
|
4
|
-
export const OPENCODE = "opencode acp";
|
|
5
|
-
export const AUGMENT = "auggie --acp";
|
|
6
|
-
export const KIRO = "kiro-cli chat acp";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export const CLAUDE_CODE = "npx -y @zed-industries/claude-code-acp", CODEX = "npx -y @zed-industries/codex-acp", GEMINI = "npx -y @google/gemini-cli --experimental-acp", OPENCODE = "opencode acp", AUGMENT = "auggie --acp", KIRO = "kiro-cli chat acp";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/generated/features.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,QAAQ;;;;CAIX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/generated/features.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,eAAe,EAAE,KAAK;IACtB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,IAAI;CAClB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
// New API
|
|
2
1
|
export { open } from "./agent.js";
|
|
3
2
|
export { Session } from "./session.js";
|
|
4
|
-
// Plan (fluent prompt builder)
|
|
5
3
|
export { createPlan } from "./think-builder.js";
|
|
6
|
-
// Thought streaming
|
|
7
4
|
export { ThoughtStream } from "./thought-stream.js";
|
|
8
|
-
// Schema helpers
|
|
9
5
|
export { schemaOf } from "./schema.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/schema.js
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a SchemaProvider from a raw JSON Schema object.
|
|
3
|
-
*
|
|
4
|
-
* This is a convenience function for users who want to pass a JSON schema
|
|
5
|
-
* directly without using a schema library like Zod or TypeBox.
|
|
6
|
-
*
|
|
7
|
-
* @typeParam T - The TypeScript type that this schema describes
|
|
8
|
-
* @param schema - A JSON Schema object describing the expected output structure
|
|
9
|
-
* @returns A SchemaProvider that wraps the given schema
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* interface Summary {
|
|
14
|
-
* title: string;
|
|
15
|
-
* points: string[];
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* const result = await agent
|
|
19
|
-
* .think(schemaOf<Summary>({
|
|
20
|
-
* type: "object",
|
|
21
|
-
* properties: {
|
|
22
|
-
* title: { type: "string" },
|
|
23
|
-
* points: { type: "array", items: { type: "string" } }
|
|
24
|
-
* },
|
|
25
|
-
* required: ["title", "points"]
|
|
26
|
-
* }))
|
|
27
|
-
* .text("Summarize this document")
|
|
28
|
-
* .run();
|
|
29
|
-
*
|
|
30
|
-
* // result is typed as Summary
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
1
|
export function schemaOf(schema) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
return {
|
|
3
|
+
toJsonSchema: () => schema
|
|
4
|
+
};
|
|
37
5
|
}
|
|
38
|
-
//# sourceMappingURL=schema.js.map
|
package/dist/session.js
CHANGED
|
@@ -1,85 +1,53 @@
|
|
|
1
1
|
import { createPlan } from "./think-builder.js";
|
|
2
|
-
/**
|
|
3
|
-
* A session for multi-turn conversations with an agent.
|
|
4
|
-
*
|
|
5
|
-
* Sessions maintain conversation context across multiple `think()` calls,
|
|
6
|
-
* allowing the agent to remember previous interactions. Create sessions
|
|
7
|
-
* using `agent.createSession()`.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
12
|
-
*
|
|
13
|
-
* // First turn
|
|
14
|
-
* const analysis = await session
|
|
15
|
-
* .think(AnalysisSchema)
|
|
16
|
-
* .text("Analyze this codebase")
|
|
17
|
-
* .run();
|
|
18
|
-
*
|
|
19
|
-
* // Second turn - agent remembers context
|
|
20
|
-
* const fixes = await session
|
|
21
|
-
* .think(FixesSchema)
|
|
22
|
-
* .text("Suggest fixes for the top issues")
|
|
23
|
-
* .run();
|
|
24
|
-
*
|
|
25
|
-
* session.close();
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
2
|
export class Session {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
close() {
|
|
80
|
-
this._closed = true;
|
|
81
|
-
// Note: ACP doesn't have an explicit session close message,
|
|
82
|
-
// we just stop using the session ID
|
|
83
|
-
}
|
|
3
|
+
_conn;
|
|
4
|
+
_sessionId;
|
|
5
|
+
_options;
|
|
6
|
+
_closed = !1;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
constructor(conn, sessionId, options) {
|
|
11
|
+
this._conn = conn, this._sessionId = sessionId, this._options = options;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The unique session identifier
|
|
15
|
+
*/
|
|
16
|
+
get sessionId() {
|
|
17
|
+
return this._sessionId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new plan for constructing a prompt with tools.
|
|
21
|
+
*
|
|
22
|
+
* Unlike `agent.think()`, prompts sent through a session maintain
|
|
23
|
+
* conversation context - the agent remembers previous interactions.
|
|
24
|
+
*
|
|
25
|
+
* @param schema - A SchemaProvider that defines the expected output structure
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = await session
|
|
30
|
+
* .think(schemaOf<{ answer: string }>({
|
|
31
|
+
* type: "object",
|
|
32
|
+
* properties: { answer: { type: "string" } },
|
|
33
|
+
* required: ["answer"]
|
|
34
|
+
* }))
|
|
35
|
+
* .text("What was the first thing I asked you?")
|
|
36
|
+
* .run();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
think(schema) {
|
|
40
|
+
if (this._closed)
|
|
41
|
+
throw new Error("Session is closed");
|
|
42
|
+
return createPlan(this._conn, schema, this._sessionId);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Close the session.
|
|
46
|
+
*
|
|
47
|
+
* After closing, no more prompts can be sent through this session.
|
|
48
|
+
* The agent connection remains open for other sessions.
|
|
49
|
+
*/
|
|
50
|
+
close() {
|
|
51
|
+
this._closed = !0;
|
|
52
|
+
}
|
|
84
53
|
}
|
|
85
|
-
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"think-builder.d.ts","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"think-builder.d.ts","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,cAAc,EAGnB,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAMlE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAyBpD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACrB;AA8ED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,IAAI,C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