@agentorg/cli 0.0.6 → 0.0.8

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 (111) hide show
  1. package/README.md +10 -7
  2. package/dist/node_modules/@agentorg/computer/LICENSE +201 -0
  3. package/dist/node_modules/@agentorg/computer/NOTICE +2 -0
  4. package/dist/node_modules/@agentorg/computer/dist/THIRD_PARTY_LICENSES.txt +1321 -0
  5. package/dist/node_modules/@agentorg/computer/dist/sdk.js +24909 -0
  6. package/dist/node_modules/@agentorg/computer/dist/types/generated/schema.d.ts +860 -0
  7. package/dist/node_modules/@agentorg/computer/dist/types/sdk.d.ts +242 -0
  8. package/dist/node_modules/@agentorg/computer/package.json +12 -0
  9. package/dist/node_modules/@agentorg/computer-connector/dist/src/index.d.ts +1 -0
  10. package/dist/node_modules/@agentorg/computer-connector/dist/src/index.js +1 -0
  11. package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.d.ts +24 -0
  12. package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.js +482 -0
  13. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.d.ts +19 -0
  14. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.js +149 -0
  15. package/dist/node_modules/@agentorg/computer-connector/package.json +33 -0
  16. package/dist/node_modules/@agentorg/computer-connector/skills/browser/SKILL.md +31 -0
  17. package/dist/node_modules/@agentorg/computer-connector/skills/computer/SKILL.md +30 -0
  18. package/dist/node_modules/@agentorg/computer-connector/skills/files/SKILL.md +28 -0
  19. package/dist/node_modules/@agentorg/computer-connector/skills/terminal/SKILL.md +39 -0
  20. package/dist/node_modules/@agentorg/computer-connector/skills/web-research/SKILL.md +29 -0
  21. package/dist/node_modules/@agentorg/hub/dist/src/router.d.ts +4 -2
  22. package/dist/node_modules/@agentorg/hub/dist/src/router.js +3 -1
  23. package/dist/node_modules/@agentorg/hub/dist/src/validate.js +16 -2
  24. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.d.ts +34 -47
  25. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.js +25 -34
  26. package/dist/node_modules/@agentorg/interfaces/dist/src/chat.d.ts +90 -50
  27. package/dist/node_modules/@agentorg/interfaces/dist/src/chat.js +69 -34
  28. package/dist/node_modules/@agentorg/interfaces/dist/src/connection.d.ts +36 -0
  29. package/dist/node_modules/@agentorg/interfaces/dist/src/connection.js +31 -0
  30. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.d.ts +19 -0
  31. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.js +25 -0
  32. package/dist/node_modules/@agentorg/interfaces/dist/src/index.d.ts +6 -4
  33. package/dist/node_modules/@agentorg/interfaces/dist/src/index.js +6 -4
  34. package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.d.ts +2 -0
  35. package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.js +2 -1
  36. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.d.ts +381 -27
  37. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.js +179 -15
  38. package/dist/node_modules/@agentorg/interfaces/dist/src/units.d.ts +460 -0
  39. package/dist/node_modules/@agentorg/interfaces/dist/src/units.js +204 -0
  40. package/dist/node_modules/@agentorg/looper/dist/src/index.d.ts +5 -0
  41. package/dist/node_modules/@agentorg/looper/dist/src/index.js +5 -0
  42. package/dist/node_modules/@agentorg/looper/dist/src/loop.d.ts +89 -0
  43. package/dist/node_modules/@agentorg/looper/dist/src/loop.js +366 -0
  44. package/dist/node_modules/@agentorg/looper/dist/src/looper.d.ts +81 -0
  45. package/dist/node_modules/@agentorg/looper/dist/src/looper.js +574 -0
  46. package/dist/node_modules/@agentorg/looper/dist/src/main.d.ts +34 -0
  47. package/dist/node_modules/@agentorg/looper/dist/src/main.js +116 -0
  48. package/dist/node_modules/@agentorg/looper/dist/src/record.d.ts +181 -0
  49. package/dist/node_modules/@agentorg/looper/dist/src/record.js +433 -0
  50. package/dist/node_modules/@agentorg/looper/dist/src/tools.d.ts +11 -0
  51. package/dist/node_modules/@agentorg/looper/dist/src/tools.js +42 -0
  52. package/dist/node_modules/@agentorg/looper/dist/src/types.d.ts +147 -0
  53. package/dist/node_modules/@agentorg/looper/dist/src/types.js +32 -0
  54. package/dist/node_modules/@agentorg/looper/package.json +24 -0
  55. package/dist/node_modules/@agentorg/manager/dist/src/activity.d.ts +18 -0
  56. package/dist/node_modules/@agentorg/manager/dist/src/activity.js +65 -0
  57. package/dist/node_modules/@agentorg/manager/dist/src/control.d.ts +134 -0
  58. package/dist/node_modules/@agentorg/manager/dist/src/control.js +1115 -0
  59. package/dist/node_modules/@agentorg/manager/dist/src/form.d.ts +40 -0
  60. package/dist/node_modules/@agentorg/manager/dist/src/form.js +191 -0
  61. package/dist/node_modules/@agentorg/manager/dist/src/manager.d.ts +4 -0
  62. package/dist/node_modules/@agentorg/manager/dist/src/manager.js +341 -189
  63. package/dist/node_modules/@agentorg/manager/dist/src/skills.d.ts +2 -0
  64. package/dist/node_modules/@agentorg/manager/dist/src/skills.js +7 -0
  65. package/dist/node_modules/@agentorg/manager/dist/src/stack.d.ts +454 -0
  66. package/dist/node_modules/@agentorg/manager/dist/src/stack.js +917 -0
  67. package/dist/node_modules/@agentorg/mcp/dist/src/connection.d.ts +2 -1
  68. package/dist/node_modules/@agentorg/mcp/dist/src/connection.js +8 -2
  69. package/dist/node_modules/@agentorg/mcp/dist/src/index.d.ts +3 -0
  70. package/dist/node_modules/@agentorg/mcp/dist/src/index.js +3 -0
  71. package/dist/node_modules/@agentorg/mcp/dist/src/kinds.d.ts +108 -0
  72. package/dist/node_modules/@agentorg/mcp/dist/src/kinds.js +95 -0
  73. package/dist/node_modules/@agentorg/mcp/dist/src/provider.d.ts +2 -2
  74. package/dist/node_modules/@agentorg/mcp/dist/src/provider.js +48 -18
  75. package/dist/node_modules/@agentorg/mcp/dist/src/public.d.ts +6 -0
  76. package/dist/node_modules/@agentorg/mcp/dist/src/public.js +72 -0
  77. package/dist/node_modules/@agentorg/sdk/dist/src/filled.d.ts +21 -0
  78. package/dist/node_modules/@agentorg/sdk/dist/src/filled.js +24 -0
  79. package/dist/node_modules/@agentorg/sdk/dist/src/index.d.ts +1 -0
  80. package/dist/node_modules/@agentorg/sdk/dist/src/index.js +1 -0
  81. package/dist/node_modules/@agentorg/shell/dist/app.css +1306 -181
  82. package/dist/node_modules/@agentorg/shell/dist/app.js +207 -166
  83. package/dist/node_modules/@agentorg/shell/package.json +6 -1
  84. package/dist/node_modules/assistant/dist/src/chats.d.ts +94 -0
  85. package/dist/node_modules/assistant/dist/src/chats.js +355 -0
  86. package/dist/node_modules/assistant/dist/src/engine.d.ts +26 -7
  87. package/dist/node_modules/assistant/dist/src/engine.js +107 -35
  88. package/dist/node_modules/assistant/dist/src/local-store.js +1 -1
  89. package/dist/node_modules/assistant/dist/src/provider.d.ts +1 -1
  90. package/dist/node_modules/assistant/dist/src/provider.js +47 -19
  91. package/dist/node_modules/assistant/dist/src/tools.d.ts +11 -28
  92. package/dist/node_modules/assistant/dist/src/tools.js +19 -40
  93. package/dist/node_modules/assistant/package.json +1 -0
  94. package/dist/src/api.js +4 -0
  95. package/dist/src/folders.d.ts +2 -0
  96. package/dist/src/folders.js +45 -0
  97. package/dist/src/gateway.d.ts +7 -1
  98. package/dist/src/gateway.js +81 -12
  99. package/dist/src/live.d.ts +17 -0
  100. package/dist/src/live.js +109 -0
  101. package/dist/src/programs.d.ts +7 -0
  102. package/dist/src/programs.js +29 -2
  103. package/dist/src/signin.d.ts +12 -3
  104. package/dist/src/signin.js +30 -6
  105. package/package.json +2 -1
  106. package/dist/node_modules/@agentorg/interfaces/dist/src/mcp-provider.d.ts +0 -88
  107. package/dist/node_modules/@agentorg/interfaces/dist/src/mcp-provider.js +0 -78
  108. package/dist/node_modules/assistant/dist/src/agent.d.ts +0 -62
  109. package/dist/node_modules/assistant/dist/src/agent.js +0 -226
  110. package/dist/node_modules/assistant/dist/src/history.d.ts +0 -97
  111. package/dist/node_modules/assistant/dist/src/history.js +0 -235
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The main loop: one per looper. It is given the messages that have come in where no piece of
3
+ * work is listening, and says whose they are: new work, or work under way. It does none of the
4
+ * work and answers nobody. It has one function to call, and each decision is one model request
5
+ * that holds nothing of the decisions before it.
6
+ */
7
+ import { head } from "./record.js";
8
+ /** What the main loop is told. */
9
+ export const MAIN_INSTRUCTIONS = `You are the front desk. You do none of the work and you answer nobody: you say whose a message is, by calling \`route\` once.
10
+
11
+ You are given the pieces of work under way, each by its id and title, and what has come in where no work is listening yet.
12
+
13
+ - Give it to a piece of work under way only when it points at that work explicitly: it names it, quotes it, or refers to what it is doing, and exactly one piece of work fits. Call \`route\` with that work's id. Its worker will read it with everything it already knows, and answer where it came in. From then on everything said there goes to that work.
14
+ - Anything else is new work, also when it is on a subject like that of work under way. Call \`route\` with no \`work\`, and a \`title\` of a few words that says what the new work is.
15
+
16
+ A wrong match stays, so when in doubt it is new work. Your only answer is the call.`;
17
+ /** The one function the main loop calls. */
18
+ export const ROUTE = {
19
+ name: "route",
20
+ description: "Says whose what came in is: a piece of work under way, or new work.",
21
+ parameters: {
22
+ type: "object",
23
+ properties: {
24
+ work: {
25
+ type: "string",
26
+ description: "The id of the work under way that it points at. Leave it out for new work.",
27
+ },
28
+ title: {
29
+ type: "string",
30
+ description: "For new work: a few words that say what it is.",
31
+ },
32
+ },
33
+ },
34
+ };
35
+ /** A work's title: the first line of `text` that says anything, in a few words. */
36
+ export const titled = (text) => head((text.split("\n").find((line) => /\S/.test(line)) ?? "").replace(/\s+/g, " ").trim(), 80);
37
+ /** The main loop is put the newest messages waiting, and the start of each: enough to place them. */
38
+ const PUT = { messages: 8, each: 4000 };
39
+ /** What has come in, as it is put to the main loop with the work under way. */
40
+ export const put = (texts, underway) => [
41
+ underway.length === 0 ? "No work is under way." : "Work under way:",
42
+ ...underway.map(({ id, title }) => `- ${id}: ${title}`),
43
+ "",
44
+ "What came in:",
45
+ texts
46
+ .slice(-PUT.messages)
47
+ .map((text) => (text.length > PUT.each ? `${head(text, PUT.each)}…` : text))
48
+ .join("\n\n"),
49
+ ].join("\n");
50
+ export function createMain(options) {
51
+ /** The decision being made now, and how to drop it. */
52
+ let deciding;
53
+ return {
54
+ /**
55
+ * Say whose `texts` are, given the work under way: one decision at a time. Nothing is said
56
+ * for a decision that is cancelled. A request the model refuses rejects, as it refused.
57
+ */
58
+ async route(texts, underway) {
59
+ let drop = () => { };
60
+ const dropped = new Promise((resolve) => {
61
+ drop = () => resolve(undefined);
62
+ });
63
+ const mine = { drop };
64
+ deciding = mine;
65
+ try {
66
+ const chosen = await Promise.race([options.chosen().then((model) => ({ model })), dropped]);
67
+ if (!chosen)
68
+ return undefined;
69
+ mine.requestId = crypto.randomUUID();
70
+ const asked = options.model.respond({
71
+ requestId: mine.requestId,
72
+ ...(chosen.model ? { model: chosen.model } : {}),
73
+ instructions: MAIN_INSTRUCTIONS,
74
+ input: [{ type: "message", role: "user", content: put(texts, underway) }],
75
+ tools: [ROUTE],
76
+ });
77
+ // A model that never answers a request it was told to cancel holds nothing up.
78
+ asked.catch(() => { });
79
+ const answer = await Promise.race([asked, dropped]);
80
+ if (!answer)
81
+ return undefined;
82
+ const call = answer.output.find((item) => item.type === "function_call" && item.name === ROUTE.name);
83
+ let said = {};
84
+ if (call?.type === "function_call")
85
+ try {
86
+ said = (JSON.parse(call.arguments) ?? {});
87
+ }
88
+ catch {
89
+ // Arguments that don't read: new work, as with no call.
90
+ }
91
+ if (underway.some(({ id }) => id === said.work))
92
+ return { work: said.work };
93
+ // Anything else starts new work, titled by what came in if the model gave no title.
94
+ if (typeof said.work === "string" && said.work !== "")
95
+ options.log.warn("The main loop named work that isn't under way; it is new work.", {
96
+ work: head(said.work, 128),
97
+ });
98
+ const title = titled(typeof said.title === "string" ? said.title : "");
99
+ return { title: title || titled(texts.join("\n")) };
100
+ }
101
+ finally {
102
+ if (deciding === mine)
103
+ deciding = undefined;
104
+ }
105
+ },
106
+ /** Drop the decision being made: its request is cancelled, and it says nothing. */
107
+ async cancel() {
108
+ const cut = deciding;
109
+ if (!cut)
110
+ return;
111
+ cut.drop();
112
+ if (cut.requestId)
113
+ await options.model.cancel({ requestId: cut.requestId }).catch(() => { });
114
+ },
115
+ };
116
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * What a loop runs on, kept in a store. A thread keeps its messages, one key each: the items a
3
+ * model reads for it, and for a tool message the line a person sees. A thread is read once, then
4
+ * kept in memory, and its oldest messages are deleted past a retention cap. A piece of work reads
5
+ * its context from the threads it follows: each message is kept once, in the thread where it is
6
+ * shown, and says which work it belongs to when that isn't its thread's own.
7
+ */
8
+ import { z } from "zod";
9
+ import { Item, type Log, type Shown, type Store } from "./types.js";
10
+ /** A message as the record keeps it. */
11
+ export declare const Entry: z.ZodObject<{
12
+ id: z.ZodString;
13
+ role: z.ZodEnum<{
14
+ assistant: "assistant";
15
+ tool: "tool";
16
+ user: "user";
17
+ }>;
18
+ text: z.ZodOptional<z.ZodString>;
19
+ at: z.ZodString;
20
+ items: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
21
+ type: z.ZodLiteral<"message">;
22
+ role: z.ZodEnum<{
23
+ assistant: "assistant";
24
+ user: "user";
25
+ }>;
26
+ content: z.ZodString;
27
+ }, z.core.$strip>, z.ZodObject<{
28
+ type: z.ZodLiteral<"function_call">;
29
+ callId: z.ZodString;
30
+ name: z.ZodString;
31
+ arguments: z.ZodString;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ type: z.ZodLiteral<"function_call_output">;
34
+ callId: z.ZodString;
35
+ output: z.ZodString;
36
+ }, z.core.$strip>], "type">>;
37
+ state: z.ZodOptional<z.ZodEnum<{
38
+ done: "done";
39
+ refused: "refused";
40
+ }>>;
41
+ joined: z.ZodOptional<z.ZodLiteral<true>>;
42
+ ahead: z.ZodOptional<z.ZodNumber>;
43
+ work: z.ZodOptional<z.ZodString>;
44
+ place: z.ZodOptional<z.ZodNumber>;
45
+ }, z.core.$strip>;
46
+ export type Entry = z.output<typeof Entry>;
47
+ /** Where a record's messages are kept in its store. */
48
+ export declare const MESSAGES = "msg/";
49
+ /** What the model is sent of the past: the newest exchanges up to this many bytes of JSON. */
50
+ export declare const INPUT_BUDGET = 400000;
51
+ /** At most this many messages are kept, in at most this many bytes, oldest deleted first. */
52
+ export declare const KEEP = 2000;
53
+ export declare const KEEP_BYTES: number;
54
+ /** The first `length` UTF-16 units of `text`, never ending inside a surrogate pair. */
55
+ export declare function head(text: string, length: number): string;
56
+ /** `text`, cut so its JSON fits `max` bytes, saying so when it is cut. */
57
+ export declare function fitted(text: string, max: number): string;
58
+ /** What the person sees of a message. */
59
+ export declare const textOf: (entry: Entry) => string;
60
+ /** A call's arguments as they are kept and shown: past their cap, a note in their place. */
61
+ export declare const argumentsOf: (args: string) => string;
62
+ /**
63
+ * A message as it is shown. A tool message whose call ran carries `tool`: the call's name, how it
64
+ * ended, its arguments and its output.
65
+ */
66
+ export declare function messageOf(entry: Entry): Shown;
67
+ /** Stored values read at once when what is kept is first loaded. */
68
+ export declare const READS = 16;
69
+ /** A user message as it is kept when said. */
70
+ export declare const userEntry: (text: string) => {
71
+ role: "user";
72
+ items: {
73
+ type: "message";
74
+ role: "user";
75
+ content: string;
76
+ }[];
77
+ };
78
+ /** A message as a thread holds it. */
79
+ interface Kept {
80
+ /** Its number in its thread. */
81
+ seq: number;
82
+ key: string;
83
+ entry: Entry;
84
+ bytes: number;
85
+ /** Set while a user message is being written, or taken: the model is sent it once stored. */
86
+ writing?: boolean;
87
+ }
88
+ interface Held {
89
+ records: Kept[];
90
+ last: number;
91
+ bytes: number;
92
+ }
93
+ /** A thread's messages in a store, by their numbers. */
94
+ export declare function createThread(store: Store, log: Log, limits?: {
95
+ keep: number;
96
+ keepBytes: number;
97
+ }): {
98
+ /** What it holds, read once. */
99
+ load: () => Promise<Held>;
100
+ /**
101
+ * Keep a message in a thread already read, at once, under `id` or its own number; `stored`
102
+ * settles when it is written and the oldest past the cap are deleted. A tool message the store
103
+ * refuses is still kept in memory, since its call has run; any other is taken out again.
104
+ */
105
+ push(held: Held, entry: Omit<Entry, "id" | "at">, id?: string): {
106
+ record: Kept;
107
+ stored: Promise<void>;
108
+ };
109
+ /**
110
+ * Keep a message as `entry` from now on: at once in memory, then in the store. A write the
111
+ * store refuses leaves it as it was.
112
+ */
113
+ rewrite(held: Held, record: Kept, entry: Entry): Promise<void>;
114
+ /** Messages before `before`, oldest first, as many as fit `limit` and `PAGE_BUDGET`. */
115
+ page(before: string | undefined, limit: number): Promise<{
116
+ messages: Shown[];
117
+ more: boolean;
118
+ }>;
119
+ };
120
+ export type Thread = ReturnType<typeof createThread>;
121
+ /**
122
+ * A piece of work's record: its messages across the threads it follows, in the order it took them.
123
+ * Its id is the name of its own thread, whose messages are its unless they name another work; in
124
+ * any other thread, the messages that name it are. A message's place is its number in its own
125
+ * thread until the work follows a second thread, and a count kept with each message after. A
126
+ * message waiting in a thread it follows, said before the work had the thread, names no work yet:
127
+ * the work takes it, in the order it was said, before it keeps anything else there.
128
+ */
129
+ export declare function createRecord(options: {
130
+ id: string;
131
+ /** The threads it follows now, its own first. */
132
+ follows(): string[];
133
+ thread(name: string): Thread;
134
+ }): {
135
+ id: string;
136
+ /**
137
+ * Keep a message of its in `thread`, one of those it follows, after any waiting there. `read`
138
+ * is given for what came of a model request that had read it up to that place: when a user
139
+ * message was said since, it is kept as `ahead` of it.
140
+ */
141
+ append(entry: Omit<Entry, "id" | "at" | "work" | "place" | "ahead">, at: {
142
+ thread: string;
143
+ id?: string;
144
+ read?: number;
145
+ }): Promise<{
146
+ entry: Entry;
147
+ thread: string;
148
+ }>;
149
+ /**
150
+ * Take the messages waiting in `thread`, which it has come to follow, as its own: `joined`,
151
+ * when a turn of its is running. It says how many there were to answer: in its own thread,
152
+ * where nothing needs taking, those said since it last did anything.
153
+ */
154
+ adopt(thread: string, joined: boolean): Promise<number>;
155
+ /** Whether it holds anything but what was said to it: it has had a turn that did something. */
156
+ begun(): Promise<boolean>;
157
+ /** Whether it has no message. */
158
+ empty(): Promise<boolean>;
159
+ /** The thread it answers in now. */
160
+ where(): Promise<string>;
161
+ /** Its first user message, for a title. */
162
+ opening(): Promise<string>;
163
+ /**
164
+ * The conversation to send: the newest exchanges (each from the user message that starts a turn
165
+ * on) that fit the budget, and always the latest two, so "go on" after a long turn still has
166
+ * that turn. When those two are over the budget, their oldest function arguments and outputs
167
+ * are left out, each call still paired with an output. A message said during a turn comes after
168
+ * whatever is `ahead` of it, so the model reads it as not yet answered. `read` is the place up
169
+ * to which every user message was read, for `append` and `saidAfter`: one still being written
170
+ * is not read yet. `thread` is where what comes of it is kept.
171
+ */
172
+ input(): Promise<{
173
+ items: Item[];
174
+ read: number;
175
+ thread: string;
176
+ }>;
177
+ /** Whether a user message of its has been stored after the place `read`, which `input` gave. */
178
+ saidAfter(read: number): Promise<boolean>;
179
+ };
180
+ export type LoopRecord = ReturnType<typeof createRecord>;
181
+ export {};