@agentorg/cli 0.0.8 → 0.0.9

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 (31) hide show
  1. package/README.md +3 -3
  2. package/dist/node_modules/@agentorg/computer/dist/types/generated/schema.d.ts +3 -0
  3. package/dist/node_modules/@agentorg/computer/package.json +1 -1
  4. package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.js +3 -3
  5. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.d.ts +1 -1
  6. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.js +34 -30
  7. package/dist/node_modules/@agentorg/computer-connector/package.json +1 -1
  8. package/dist/node_modules/@agentorg/interfaces/dist/src/index.d.ts +0 -1
  9. package/dist/node_modules/@agentorg/interfaces/dist/src/index.js +0 -1
  10. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.d.ts +1 -1
  11. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.js +1 -1
  12. package/dist/node_modules/@agentorg/looper/dist/src/loop.d.ts +17 -8
  13. package/dist/node_modules/@agentorg/looper/dist/src/loop.js +80 -41
  14. package/dist/node_modules/@agentorg/looper/dist/src/looper.d.ts +39 -5
  15. package/dist/node_modules/@agentorg/looper/dist/src/looper.js +290 -102
  16. package/dist/node_modules/@agentorg/looper/dist/src/main.d.ts +73 -17
  17. package/dist/node_modules/@agentorg/looper/dist/src/main.js +166 -77
  18. package/dist/node_modules/@agentorg/looper/dist/src/record.d.ts +76 -18
  19. package/dist/node_modules/@agentorg/looper/dist/src/record.js +190 -111
  20. package/dist/node_modules/@agentorg/shell/dist/app.css +255 -276
  21. package/dist/node_modules/@agentorg/shell/dist/app.js +144 -147
  22. package/dist/node_modules/assistant/dist/src/chats.d.ts +10 -5
  23. package/dist/node_modules/assistant/dist/src/chats.js +5 -4
  24. package/dist/node_modules/assistant/dist/src/engine.js +10 -4
  25. package/dist/node_modules/chatgpt/dist/src/account.js +1 -1
  26. package/dist/src/gateway.js +0 -3
  27. package/package.json +1 -1
  28. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.d.ts +0 -19
  29. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.js +0 -25
  30. package/dist/src/folders.d.ts +0 -2
  31. package/dist/src/folders.js +0 -45
@@ -13,12 +13,16 @@ type Input<M extends keyof (typeof chat)["methods"]> = z.output<(typeof chat)["m
13
13
  type Emitted<E extends keyof (typeof chat)["events"]> = z.input<(typeof chat)["events"][E]["payload"]>;
14
14
  export declare function createChats(options: {
15
15
  store: Store;
16
- /** The agent's model, and what a request to it says and offers, as its looper asks for them. */
16
+ /**
17
+ * The agent's model, and what a request to it says and offers, as its looper asks for them;
18
+ * `voice` is the agent's own instructions, which its main loop speaks as.
19
+ */
17
20
  model: Model;
18
21
  request(): Promise<{
19
22
  instructions: string;
20
23
  tools: Tool[];
21
24
  model?: string | undefined;
25
+ voice?: string | undefined;
22
26
  }>;
23
27
  /** Whether the agent is stopped when its chats are first held. */
24
28
  stopped: boolean;
@@ -31,10 +35,11 @@ export declare function createChats(options: {
31
35
  log: Log;
32
36
  }): {
33
37
  /**
34
- * Say a message in a chat, or in a new chat it starts. A new chat's first message is put to
35
- * the agent's main loop, which gives it to new work or to work in a turn; from then on the
36
- * chat's messages are that work's: with no turn of it running one starts a turn, and a turn
37
- * running takes it at its next model request.
38
+ * Say a message in a chat, or in a new chat it starts. A message in a chat no work follows is
39
+ * put to the agent's main loop. When that answers it itself, the chat stays no work's, and its
40
+ * next message is put to the main loop too. When it gives it to new work or to work there is,
41
+ * the chat's messages are that work's from then on: with no turn of it running one starts a
42
+ * turn, and a turn running takes it at its next model request.
38
43
  */
39
44
  send({ chat, text }: Input<"send">): Promise<{
40
45
  chat: string;
@@ -263,10 +263,11 @@ export function createChats(options) {
263
263
  };
264
264
  return {
265
265
  /**
266
- * Say a message in a chat, or in a new chat it starts. A new chat's first message is put to
267
- * the agent's main loop, which gives it to new work or to work in a turn; from then on the
268
- * chat's messages are that work's: with no turn of it running one starts a turn, and a turn
269
- * running takes it at its next model request.
266
+ * Say a message in a chat, or in a new chat it starts. A message in a chat no work follows is
267
+ * put to the agent's main loop. When that answers it itself, the chat stays no work's, and its
268
+ * next message is put to the main loop too. When it gives it to new work or to work there is,
269
+ * the chat's messages are that work's from then on: with no turn of it running one starts a
270
+ * turn, and a turn running takes it at its next model request.
270
271
  */
271
272
  async send({ chat, text }) {
272
273
  if (chat !== undefined) {
@@ -29,9 +29,9 @@ export function startEngine(ctx, options) {
29
29
  */
30
30
  const request = async () => {
31
31
  const settings = ctx.slots.settings.bound ? await ctx.slots.settings.call.get({}) : undefined;
32
- const told = settings
33
- ? instructionsWith(settings.instructions, settings.skills)
34
- : { instructions: options.instructions(), leftOut: [] };
32
+ // The agent's own instructions: who its main loop speaks as, with nothing of its skills.
33
+ const voice = settings ? settings.instructions : options.instructions();
34
+ const told = instructionsWith(voice, settings?.skills ?? []);
35
35
  const own = settings?.skills.length ? [skillTool(ctx.slots.settings)] : [];
36
36
  // In the order they came, each asked at once so one slow server delays only itself.
37
37
  const exposed = await Promise.all(ctx
@@ -41,7 +41,13 @@ export function startEngine(ctx, options) {
41
41
  const fitted = offered([...own, ...exposed.flatMap((one) => one.candidates)]);
42
42
  const leftOut = [...told.leftOut, ...exposed.flatMap((one) => one.leftOut), ...fitted.leftOut];
43
43
  report(leftOut);
44
- return { instructions: told.instructions, tools: fitted.tools, model: await chosen(), leftOut };
44
+ return {
45
+ instructions: told.instructions,
46
+ tools: fitted.tools,
47
+ model: await chosen(),
48
+ voice,
49
+ leftOut,
50
+ };
45
51
  };
46
52
  /** The model slot as the looper asks it: what it refuses is told with its code. */
47
53
  const model = {
@@ -6,7 +6,7 @@ import { AGENT_NAME, AUTHORIZE, DYNAMIC_CLIENT, discover, GrantError, grant, ISS
6
6
  const PENDING_FOR = 10 * 60_000;
7
7
  const MAX_PENDING = 16;
8
8
  const REFRESH_BEFORE = 5 * 60_000;
9
- export const notSignedIn = () => new Refused("not_signed_in", "Not signed in to ChatGPT. Continue with ChatGPT to sign in.");
9
+ export const notSignedIn = () => new Refused("not_signed_in", "Not signed in to ChatGPT. Sign in to it to go on.");
10
10
  export const notEligible = () => new Refused("ineligible", "This ChatGPT account isn't eligible to use its plan in this app. Signing in again won't change that.");
11
11
  const unreachable = () => new Refused("unavailable", "OpenAI couldn't be reached. Try again later.");
12
12
  const address = (url) => `${url.origin}${url.pathname}`;
@@ -9,7 +9,6 @@ import { describeInterface, Refused } from "@agentorg/sdk";
9
9
  import { connect } from "@agentorg/sdk/client";
10
10
  import { WebSocketServer } from "ws";
11
11
  import { serveSocket } from "./api.js";
12
- import { callFolders } from "./folders.js";
13
12
  import { LIVE_MAX, pipeLive } from "./live.js";
14
13
  import { Notes } from "./notes.js";
15
14
  import { oauthRoute } from "./oauth.js";
@@ -123,8 +122,6 @@ export async function startApp(options) {
123
122
  async call(slot, method, input) {
124
123
  if (slot === "store")
125
124
  return notes.call(method, input);
126
- if (slot === "folders")
127
- return callFolders(method, input);
128
125
  const exposed = Object.hasOwn(SLOTS, slot) ? undefined : exposedSlot(slot);
129
126
  if (!exposed && !Object.hasOwn(SLOTS, slot))
130
127
  throw new Refused("invalid", `The person has no slot ${slot}.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentorg/cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "AgentOrg as one app: the Hub, the person's gateway and the shell, on loopback.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- /** The most folders one answer names. */
3
- export declare const FOLDERS_MAX = 2000;
4
- /**
5
- * `folders@1`: the folders on the machine the app runs on, for a person choosing one. It names
6
- * folders and nothing else. `list` starts at the person's home folder; `parent` is absent at the
7
- * top. Refused `unknown` when there's no such folder, `invalid` for a path that isn't absolute.
8
- */
9
- export declare const folders: import("@agentorg/sdk").RpcInterface<"folders", {
10
- list: import("@agentorg/sdk").MethodSpec<z.ZodObject<{
11
- path: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>, z.ZodObject<{
13
- path: z.ZodString;
14
- parent: z.ZodOptional<z.ZodString>;
15
- folders: z.ZodArray<z.ZodObject<{
16
- name: z.ZodString;
17
- }, z.core.$strip>>;
18
- }, z.core.$strip>>;
19
- }, {}, 1>;
@@ -1,25 +0,0 @@
1
- import { defineInterface, method } from "@agentorg/sdk";
2
- import { z } from "zod";
3
- /** The most folders one answer names. */
4
- export const FOLDERS_MAX = 2000;
5
- const Path = z.string().min(1).max(4096);
6
- /**
7
- * `folders@1`: the folders on the machine the app runs on, for a person choosing one. It names
8
- * folders and nothing else. `list` starts at the person's home folder; `parent` is absent at the
9
- * top. Refused `unknown` when there's no such folder, `invalid` for a path that isn't absolute.
10
- */
11
- export const folders = defineInterface({
12
- name: "folders",
13
- major: 1,
14
- kind: "rpc",
15
- methods: {
16
- list: method({
17
- input: z.object({ path: Path.optional() }),
18
- output: z.object({
19
- path: Path,
20
- parent: Path.optional(),
21
- folders: z.array(z.object({ name: z.string().max(4096) })).max(FOLDERS_MAX),
22
- }),
23
- }),
24
- },
25
- });
@@ -1,2 +0,0 @@
1
- /** One `folders@1` call, checked as a call through the Hub would be. */
2
- export declare function callFolders(method: string, input: unknown): Promise<unknown>;
@@ -1,45 +0,0 @@
1
- import { readdir, stat } from "node:fs/promises";
2
- import { homedir } from "node:os";
3
- import { dirname, isAbsolute, join, normalize } from "node:path";
4
- import { FOLDERS_MAX, folders } from "@agentorg/interfaces";
5
- import { Refused } from "@agentorg/sdk";
6
- async function isFolder(at, entry) {
7
- if (entry.isDirectory())
8
- return true;
9
- if (!entry.isSymbolicLink())
10
- return false;
11
- return stat(join(at, entry.name)).then((found) => found.isDirectory(), () => false);
12
- }
13
- async function list(path) {
14
- if (path !== undefined && !isAbsolute(path))
15
- throw new Refused("invalid", "A folder's path starts at the top of the disk.");
16
- const at = path === undefined ? homedir() : normalize(path);
17
- const entries = await readdir(at, { withFileTypes: true }).catch((error) => {
18
- if (error.code === "ENOENT" || error.code === "ENOTDIR")
19
- throw new Refused("unknown", "There's no such folder.");
20
- throw new Refused("invalid", "That folder can't be read.");
21
- });
22
- // Dot folders stay out of the list, as in a file picker; a path can still be typed.
23
- const shown = entries.filter((entry) => !entry.name.startsWith("."));
24
- const kept = await Promise.all(shown.map((entry) => isFolder(at, entry)));
25
- const names = shown
26
- .filter((_, i) => kept[i])
27
- .map((entry) => entry.name)
28
- .sort((a, b) => a.localeCompare(b))
29
- .slice(0, FOLDERS_MAX);
30
- const parent = dirname(at);
31
- return {
32
- path: at,
33
- ...(parent === at ? {} : { parent }),
34
- folders: names.map((name) => ({ name })),
35
- };
36
- }
37
- /** One `folders@1` call, checked as a call through the Hub would be. */
38
- export function callFolders(method, input) {
39
- if (method !== "list")
40
- throw new Refused("invalid", `folders has no method ${method}.`);
41
- const parsed = folders.methods.list.input.safeParse(input);
42
- if (!parsed.success)
43
- throw new Refused("invalid", `folders.list: ${parsed.error.message}`);
44
- return list(parsed.data.path);
45
- }