@ottocode/sdk 0.1.286 → 0.1.288
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/package.json +1 -1
- package/src/core/src/index.ts +5 -0
- package/src/core/src/tools/builtin/fs/index.ts +0 -4
- package/src/core/src/tools/builtin/patch.txt +11 -0
- package/src/core/src/tools/lazy/index.ts +12 -0
- package/src/core/src/tools/lazy/load-tools.ts +56 -0
- package/src/core/src/tools/lazy/registry.ts +51 -0
- package/src/core/src/tools/lazy/simulator.ts +1039 -0
- package/src/core/src/tools/loader.ts +10 -0
- package/src/index.ts +5 -0
- package/src/providers/src/catalog.ts +7322 -3898
- package/src/providers/src/oauth-models.ts +1 -0
package/package.json
CHANGED
package/src/core/src/index.ts
CHANGED
|
@@ -52,6 +52,11 @@ export type {
|
|
|
52
52
|
export { buildFsTools } from './tools/builtin/fs/index';
|
|
53
53
|
export { buildGitTools } from './tools/builtin/git';
|
|
54
54
|
export { buildTerminalTool } from './tools/builtin/terminal';
|
|
55
|
+
export {
|
|
56
|
+
buildLazyToolsRecord,
|
|
57
|
+
buildLoadFirstPartyToolsTool,
|
|
58
|
+
buildSimulatorTool,
|
|
59
|
+
} from './tools/lazy/index';
|
|
55
60
|
|
|
56
61
|
// =======================
|
|
57
62
|
// Terminals
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Tool } from 'ai';
|
|
2
2
|
import { buildEditTool } from './edit.ts';
|
|
3
3
|
import { buildReadTool } from './read.ts';
|
|
4
|
-
import { buildReadImageTool } from './read-image.ts';
|
|
5
4
|
import { buildMultiEditTool } from './multiedit.ts';
|
|
6
5
|
import { buildWriteTool } from './write.ts';
|
|
7
6
|
import { buildCopyIntoTool } from './copy-into.ts';
|
|
8
|
-
import { buildCopyAttachmentTool } from './copy-attachment.ts';
|
|
9
7
|
import { buildLsTool } from './ls.ts';
|
|
10
8
|
import { buildTreeTool } from './tree.ts';
|
|
11
9
|
import { buildPwdTool } from './pwd.ts';
|
|
@@ -16,12 +14,10 @@ export function buildFsTools(
|
|
|
16
14
|
): Array<{ name: string; tool: Tool }> {
|
|
17
15
|
const out: Array<{ name: string; tool: Tool }> = [];
|
|
18
16
|
out.push(buildReadTool(projectRoot));
|
|
19
|
-
out.push(buildReadImageTool(projectRoot));
|
|
20
17
|
out.push(buildEditTool(projectRoot));
|
|
21
18
|
out.push(buildMultiEditTool(projectRoot));
|
|
22
19
|
out.push(buildWriteTool(projectRoot));
|
|
23
20
|
out.push(buildCopyIntoTool(projectRoot));
|
|
24
|
-
out.push(buildCopyAttachmentTool(projectRoot));
|
|
25
21
|
out.push(buildLsTool(projectRoot));
|
|
26
22
|
out.push(buildTreeTool(projectRoot));
|
|
27
23
|
out.push(buildPwdTool());
|
|
@@ -58,6 +58,17 @@ new block after line 200
|
|
|
58
58
|
Line-number mode is concise but fragile if the file changes after you read it.
|
|
59
59
|
Prefer text/context patches for small edits.
|
|
60
60
|
|
|
61
|
+
When deleting a contiguous block larger than 10 lines, prefer line-number deletion:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
*** Begin Patch
|
|
65
|
+
*** Delete Lines in: path/to/file.ts
|
|
66
|
+
*** Lines: start-end
|
|
67
|
+
*** End Patch
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Do not reproduce the whole deleted block unless line numbers are unavailable or uncertain.
|
|
71
|
+
|
|
61
72
|
---
|
|
62
73
|
|
|
63
74
|
## Standard mode: Add / Update / Delete
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
buildLazyToolCatalogDescription,
|
|
3
|
+
buildLoadToolsTool,
|
|
4
|
+
type LazyToolBrief,
|
|
5
|
+
} from './load-tools.ts';
|
|
6
|
+
export {
|
|
7
|
+
buildLazyToolsRecord,
|
|
8
|
+
buildLoadFirstPartyToolsTool,
|
|
9
|
+
getLazyToolDefinitions,
|
|
10
|
+
type LazyToolDefinition,
|
|
11
|
+
} from './registry.ts';
|
|
12
|
+
export { buildSimulatorTool } from './simulator.ts';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { tool, type Tool } from 'ai';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
|
+
|
|
4
|
+
export type LazyToolBrief = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function buildLazyToolCatalogDescription(
|
|
10
|
+
briefs: LazyToolBrief[],
|
|
11
|
+
): string {
|
|
12
|
+
if (briefs.length === 0) return 'No lazy tools available.';
|
|
13
|
+
return briefs
|
|
14
|
+
.map((brief) => `- ${brief.name}: ${brief.description.slice(0, 180)}`)
|
|
15
|
+
.join('\n');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildLoadToolsTool(briefs: LazyToolBrief[]): {
|
|
19
|
+
name: string;
|
|
20
|
+
tool: Tool;
|
|
21
|
+
} {
|
|
22
|
+
const catalog = buildLazyToolCatalogDescription(briefs);
|
|
23
|
+
const validNames = new Set(briefs.map((brief) => brief.name));
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
name: 'load_tools',
|
|
27
|
+
tool: tool({
|
|
28
|
+
description: `Load first-party tools by name so they become available for use in the next step. Call this before using a listed tool.\n\nAvailable tools:\n${catalog}`,
|
|
29
|
+
inputSchema: z.object({
|
|
30
|
+
tools: z
|
|
31
|
+
.array(z.string())
|
|
32
|
+
.describe('Array of first-party tool names to load.'),
|
|
33
|
+
}),
|
|
34
|
+
execute: async ({ tools: requested }) => {
|
|
35
|
+
const loaded: string[] = [];
|
|
36
|
+
const notFound: string[] = [];
|
|
37
|
+
for (const name of requested) {
|
|
38
|
+
if (validNames.has(name)) {
|
|
39
|
+
loaded.push(name);
|
|
40
|
+
} else {
|
|
41
|
+
notFound.push(name);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
loaded,
|
|
47
|
+
...(notFound.length > 0 ? { notFound } : {}),
|
|
48
|
+
message:
|
|
49
|
+
loaded.length > 0
|
|
50
|
+
? `Loaded ${loaded.length} tool(s). They are now available for use.`
|
|
51
|
+
: 'No valid tools to load.',
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Tool } from 'ai';
|
|
2
|
+
import { buildCopyAttachmentTool } from '../builtin/fs/copy-attachment.ts';
|
|
3
|
+
import { buildReadImageTool } from '../builtin/fs/read-image.ts';
|
|
4
|
+
import { buildSimulatorTool } from './simulator.ts';
|
|
5
|
+
import { buildLoadToolsTool, type LazyToolBrief } from './load-tools.ts';
|
|
6
|
+
|
|
7
|
+
export type LazyToolDefinition = LazyToolBrief & {
|
|
8
|
+
build: (projectRoot: string) => { name: string; tool: Tool };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function getLazyToolDefinitions(): LazyToolDefinition[] {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: 'simulator',
|
|
15
|
+
description:
|
|
16
|
+
'Control Apple Simulator via serve-sim: start, status, click, type, button, rotate, screenshot, accessibility tree, foreground app, logs, stop.',
|
|
17
|
+
build: buildSimulatorTool,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'read_image',
|
|
21
|
+
description:
|
|
22
|
+
'Read and inspect a local image file such as a screenshot, icon, or diagram.',
|
|
23
|
+
build: buildReadImageTool,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'copy_attachment_to_project',
|
|
27
|
+
description:
|
|
28
|
+
'Copy an original uploaded chat attachment into the project without recompression.',
|
|
29
|
+
build: buildCopyAttachmentTool,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function buildLazyToolsRecord(
|
|
35
|
+
projectRoot: string,
|
|
36
|
+
): Record<string, Tool> {
|
|
37
|
+
const record: Record<string, Tool> = {};
|
|
38
|
+
for (const definition of getLazyToolDefinitions()) {
|
|
39
|
+
const built = definition.build(projectRoot);
|
|
40
|
+
record[built.name] = built.tool;
|
|
41
|
+
}
|
|
42
|
+
return record;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function buildLoadFirstPartyToolsTool(): { name: string; tool: Tool } {
|
|
46
|
+
const briefs = getLazyToolDefinitions().map(({ name, description }) => ({
|
|
47
|
+
name,
|
|
48
|
+
description,
|
|
49
|
+
}));
|
|
50
|
+
return buildLoadToolsTool(briefs);
|
|
51
|
+
}
|