@chloejs/core 0.2.3 → 0.2.4

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.
@@ -4,7 +4,7 @@
4
4
  // write. All the model chooses is how far back and how many.
5
5
  import { z } from "zod";
6
6
 
7
- import { messages, oneMessage } from "#chloe/services/gmailService.ts";
7
+ import { readEmailMessages, readOneEmailMessage } from "#chloe/services/gmailService.ts";
8
8
  import { tool } from "#chloe/model/tool.ts";
9
9
 
10
10
  interface Options {
@@ -46,7 +46,7 @@ export function read_mail({
46
46
  }),
47
47
  execute: ({ days: back, limit, messageId }) =>
48
48
  messageId
49
- ? oneMessage({ search, what, days: back ?? days, limit: limit ?? 10, messageId })
50
- : messages({ search, days: back ?? days, limit: limit ?? 10 }),
49
+ ? readOneEmailMessage({ search, what, days: back ?? days, limit: limit ?? 10, messageId })
50
+ : readEmailMessages({ search, days: back ?? days, limit: limit ?? 10 }),
51
51
  });
52
52
  }
@@ -8,7 +8,7 @@ import { existsSync, readdirSync } from "node:fs";
8
8
  import { z } from "zod";
9
9
 
10
10
  import { agentDir } from "#chloe/core/paths.ts";
11
- import { script, scripts } from "#chloe/services/scriptsService.ts";
11
+ import { listScripts, runScripts as runOne } from "#chloe/services/scriptsService.ts";
12
12
  import { tool, type Tools } from "#chloe/model/tool.ts";
13
13
 
14
14
  /** A tool that runs one file from that agent's own `scripts/` folder. */
@@ -25,8 +25,8 @@ export function runScript(agent: string) {
25
25
  }),
26
26
  execute: async ({ script: name, args = [], timeoutSeconds }) =>
27
27
  name === "list"
28
- ? { scripts: await scripts(agent) }
29
- : script(agent, name, args, { timeoutMs: (timeoutSeconds ?? 300) * 1000 }),
28
+ ? { scripts: await listScripts(agent) }
29
+ : runOne(agent, name, args, { timeoutMs: (timeoutSeconds ?? 300) * 1000 }),
30
30
  });
31
31
  }
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chloejs/core",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "description": "A job runner where asking a model is one kind of step.",
6
6
  "exports": {
@@ -35,7 +35,7 @@ export interface Message {
35
35
  }
36
36
 
37
37
  /** What the bound search matches. Nothing here widens it. */
38
- export async function messages({
38
+ export async function readEmailMessages({
39
39
  search,
40
40
  days = 7,
41
41
  limit = 10,
@@ -55,7 +55,7 @@ export async function messages({
55
55
  * filter. Same check as the tool, because a job is not more trusted than a
56
56
  * model here: it is only more predictable.
57
57
  */
58
- export async function oneMessage({
58
+ export async function readOneEmailMessage({
59
59
  search,
60
60
  what,
61
61
  days = 7,
@@ -68,7 +68,7 @@ export async function oneMessage({
68
68
  limit?: number;
69
69
  messageId: string;
70
70
  }): Promise<{ query: string; message: unknown }> {
71
- const { query, messages: found } = await messages({ search, days, limit });
71
+ const { query, messages: found } = await readEmailMessages({ search, days, limit });
72
72
  if (!found.some((m) => m.id === messageId || m.threadId === messageId)) {
73
73
  throw new Error(
74
74
  `That message is not in ${what}. You can only read what this search listed. ` +
package/services/index.ts CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  export { run, type Result } from "./runService.ts";
12
12
  export { sendEmail, type EmailSender } from "./emailService.ts";
13
- export { messages, oneMessage, type Message as Mail } from "./gmailService.ts";
13
+ export { readEmailMessages, readOneEmailMessage, type Message as Mail } from "./gmailService.ts";
14
14
  export { listFiles, readFiles, searchFiles, writeFiles } from "./filesService.ts";
15
- export { script, scripts } from "./scriptsService.ts";
15
+ export { listScripts, runScripts } from "./scriptsService.ts";
16
16
  export { readPage, htmlToText, isPrivate, type Page } from "./webService.ts";
@@ -14,7 +14,7 @@ import { settings } from "#chloe/core/settings.ts";
14
14
  import { run, type Result } from "./runService.ts";
15
15
 
16
16
  /** What this agent has in scripts/, sorted. Nothing hidden. */
17
- export async function scripts(agent: string): Promise<string[]> {
17
+ export async function listScripts(agent: string): Promise<string[]> {
18
18
  const dir = `${agentDir(agent)}/scripts`;
19
19
  const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
20
20
  return entries
@@ -30,13 +30,13 @@ export async function scripts(agent: string): Promise<string[]> {
30
30
  * `cwd` defaults to the scripts folder, so a script may use relative paths.
31
31
  * An agent whose scripts work on a tree somewhere else passes that instead.
32
32
  */
33
- export async function script(
33
+ export async function runScripts(
34
34
  agent: string,
35
35
  name: string,
36
36
  args: string[] = [],
37
37
  { timeoutMs = 300_000, cwd }: { timeoutMs?: number; cwd?: string } = {},
38
38
  ): Promise<Result & { script: string; args: string[] }> {
39
- const available = await scripts(agent);
39
+ const available = await listScripts(agent);
40
40
  if (!available.includes(name)) {
41
41
  throw new Error(`No script called ${JSON.stringify(name)}. You have: ${available.join(", ")}`);
42
42
  }