@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
@@ -1,235 +0,0 @@
1
- /**
2
- * The assistant's record of its chat, kept in its `store` slot: one key per message, holding the
3
- * Responses items it stands for, and for a tool message the line the person sees. It is read once,
4
- * then kept in memory, and the oldest messages are deleted past a retention cap.
5
- */
6
- import { Item } from "@agentorg/interfaces";
7
- import { z } from "zod";
8
- const Entry = z.object({
9
- id: z.string(),
10
- role: z.enum(["user", "assistant", "tool"]),
11
- /** What the person sees, for a tool message; the others show their message items. */
12
- text: z.string().optional(),
13
- at: z.string(),
14
- items: z.array(Item),
15
- /** For a tool message whose call ran: how it ended. */
16
- state: z.enum(["done", "refused"]).optional(),
17
- });
18
- const PREFIX = "msg/";
19
- const keyOf = (seq) => `${PREFIX}${String(seq).padStart(12, "0")}`;
20
- /** What the model is sent of the past: the newest exchanges up to this many bytes of JSON. */
21
- export const INPUT_BUDGET = 400_000;
22
- /** At most this many messages are kept, in at most this many bytes, oldest deleted first. */
23
- export const KEEP = 2000;
24
- export const KEEP_BYTES = 16 * 1024 * 1024;
25
- /** A stored message's text, and a call's arguments, are cut to fit these, in bytes of JSON. */
26
- const MAX_TEXT = 192 * 1024;
27
- const MAX_ARGUMENTS = 16 * 1024;
28
- /** A history page stays well inside one frame. */
29
- const PAGE_BUDGET = 512 * 1024;
30
- const encoder = new TextEncoder();
31
- const size = (value) => encoder.encode(JSON.stringify(value)).byteLength;
32
- const LEFT_OUT = "(Left out: the conversation was too large to send it.)";
33
- const ARGUMENTS_LEFT_OUT = '{"left_out":"too large to keep"}';
34
- /** The first `length` UTF-16 units of `text`, never ending inside a surrogate pair. */
35
- export function head(text, length) {
36
- const cut = text.slice(0, length);
37
- return /[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut;
38
- }
39
- /** `text`, cut so its JSON fits `max` bytes, saying so when it is cut. */
40
- export function fitted(text, max) {
41
- let kept = text;
42
- for (let bytes = size(kept); bytes > max; bytes = size(kept))
43
- kept = `${head(kept, Math.floor((kept.length * max) / bytes) - 16)}… (cut)`;
44
- return kept;
45
- }
46
- /** A chat message shows at most this much; the record keeps all of it. */
47
- const MAX_SHOWN = 100_000;
48
- /** What the person sees of a message. */
49
- export const textOf = (entry) => head(entry.text ??
50
- entry.items.flatMap((item) => (item.type === "message" ? [item.content] : [])).join(""), MAX_SHOWN);
51
- /** A call's arguments as they are kept and shown: past their cap, a note in their place. */
52
- export const argumentsOf = (args) => size(args) > MAX_ARGUMENTS ? ARGUMENTS_LEFT_OUT : args;
53
- /**
54
- * A message as the chat shows it. A tool message whose call ran carries `tool`: the call's name,
55
- * how it ended, its arguments and its output.
56
- */
57
- export function messageOf(entry) {
58
- const message = { id: entry.id, role: entry.role, text: textOf(entry), at: entry.at };
59
- const call = entry.items.find((item) => item.type === "function_call");
60
- if (entry.role !== "tool" || !entry.state || !call)
61
- return message;
62
- const output = entry.items.find((item) => item.type === "function_call_output");
63
- return {
64
- ...message,
65
- tool: {
66
- name: head(call.name, 128),
67
- state: entry.state,
68
- input: head(call.arguments, MAX_SHOWN),
69
- ...(output ? { output: head(output.output, MAX_SHOWN) } : {}),
70
- },
71
- };
72
- }
73
- /** A message as it is stored: each text once, and nothing past its cap. */
74
- const kept = (entry) => ({
75
- ...entry,
76
- items: entry.items.map((item) => {
77
- if (item.type === "message")
78
- return { ...item, content: fitted(item.content, MAX_TEXT) };
79
- if (item.type === "function_call_output")
80
- return { ...item, output: fitted(item.output, MAX_TEXT) };
81
- return { ...item, arguments: argumentsOf(item.arguments) };
82
- }),
83
- });
84
- /** Stored messages read at once when the record is first loaded. */
85
- const READS = 16;
86
- export function createHistory(store, log, limits = { keep: KEEP, keepBytes: KEEP_BYTES }) {
87
- let loaded;
88
- const load = () => {
89
- if (loaded)
90
- return loaded;
91
- const attempt = (async () => {
92
- const records = [];
93
- let last = 0;
94
- let bytes = 0;
95
- let after;
96
- do {
97
- const page = await store.list({ prefix: PREFIX, limit: 1000, ...(after ? { after } : {}) });
98
- // A few at a time, in order: a long record shouldn't hold up the first send one read at
99
- // a time, nor flood the Hub.
100
- for (let at = 0; at < page.keys.length; at += READS) {
101
- const keys = page.keys.slice(at, at + READS);
102
- const values = await Promise.all(keys.map((key) => store.get({ key })));
103
- keys.forEach((key, i) => {
104
- last = Math.max(last, Number(key.slice(PREFIX.length)) || 0);
105
- const parsed = Entry.safeParse(values[i]?.value);
106
- if (!parsed.success) {
107
- log.warn("A stored message didn't read back; it is left out.", { key });
108
- return;
109
- }
110
- const record = { key, entry: parsed.data, bytes: size(parsed.data) };
111
- records.push(record);
112
- bytes += record.bytes;
113
- });
114
- }
115
- after = page.next ?? undefined;
116
- } while (after);
117
- return { records, last, bytes };
118
- })();
119
- loaded = attempt;
120
- attempt.catch(() => {
121
- if (loaded === attempt)
122
- loaded = undefined;
123
- });
124
- return attempt;
125
- };
126
- return {
127
- /**
128
- * Keep a message, under `id` or its own number, and delete the oldest past the cap. A tool
129
- * message the store refuses is still kept in memory, since its call has run.
130
- */
131
- async append(entry, id) {
132
- const state = await load();
133
- const key = keyOf(++state.last);
134
- const record = {
135
- key,
136
- entry: kept({ id: id ?? key.slice(PREFIX.length), at: new Date().toISOString(), ...entry }),
137
- bytes: 0,
138
- };
139
- record.bytes = size(record.entry);
140
- state.records.push(record);
141
- state.bytes += record.bytes;
142
- try {
143
- await store.set({ key, value: record.entry });
144
- }
145
- catch (error) {
146
- if (entry.role !== "tool") {
147
- state.records.splice(state.records.indexOf(record), 1);
148
- state.bytes -= record.bytes;
149
- throw error;
150
- }
151
- log.error("A tool message couldn't be stored; it is kept until a restart.", {
152
- error: String(error),
153
- });
154
- }
155
- while (state.records.length > 1 &&
156
- (state.records.length > limits.keep || state.bytes > limits.keepBytes)) {
157
- const oldest = state.records.shift();
158
- state.bytes -= oldest.bytes;
159
- await store.delete({ key: oldest.key }).catch((error) => log.warn("An old message couldn't be deleted.", {
160
- key: oldest.key,
161
- error: String(error),
162
- }));
163
- }
164
- return record.entry;
165
- },
166
- /** Forget everything after the message `id`: a retry takes the place of what followed it. */
167
- async dropAfter(id) {
168
- const state = await load();
169
- const at = state.records.findLastIndex((record) => record.entry.id === id);
170
- if (at === -1)
171
- return;
172
- for (const gone of state.records.splice(at + 1)) {
173
- state.bytes -= gone.bytes;
174
- await store.delete({ key: gone.key }).catch((error) => log.warn("A replaced message couldn't be deleted.", {
175
- key: gone.key,
176
- error: String(error),
177
- }));
178
- }
179
- },
180
- /** The person's last message, if any. */
181
- async lastUser() {
182
- return (await load()).records.findLast((record) => record.entry.role === "user")?.entry;
183
- },
184
- /** Messages before `before`, oldest first, as many as fit `limit` and one frame. */
185
- async page(before, limit) {
186
- const { records } = await load();
187
- const end = before === undefined
188
- ? records.length
189
- : records.findIndex((record) => record.entry.id === before);
190
- const messages = [];
191
- let bytes = 0;
192
- let start = Math.max(end, 0);
193
- while (start > 0 && messages.length < limit) {
194
- const { entry } = records[start - 1];
195
- const message = messageOf(entry);
196
- bytes += size(message);
197
- if (bytes > PAGE_BUDGET && messages.length > 0)
198
- break;
199
- messages.unshift(message);
200
- start--;
201
- }
202
- return { messages, more: start > 0 };
203
- },
204
- /**
205
- * The conversation to send: the newest whole exchanges (each from a user message on) that fit
206
- * the budget, and always the latest one. A latest one that alone is over the budget has its
207
- * oldest function arguments and outputs left out, each call still paired with an output.
208
- */
209
- async input() {
210
- const { records } = await load();
211
- const exchanges = [];
212
- for (const { entry } of records) {
213
- if (entry.role === "user" || exchanges.length === 0)
214
- exchanges.push([]);
215
- exchanges.at(-1)?.push(...entry.items);
216
- }
217
- let total = exchanges.reduce((sum, items) => sum + size(items), 0);
218
- while (exchanges.length > 1 && total > INPUT_BUDGET)
219
- total -= size(exchanges.shift());
220
- const items = exchanges.flat();
221
- for (let i = 0; i < items.length && total > INPUT_BUDGET; i++) {
222
- const item = items[i];
223
- if (item.type === "function_call_output" && item.output !== LEFT_OUT) {
224
- total -= size(item.output) - size(LEFT_OUT);
225
- items[i] = { ...item, output: LEFT_OUT };
226
- }
227
- else if (item.type === "function_call" && item.arguments !== ARGUMENTS_LEFT_OUT) {
228
- total -= size(item.arguments) - size(ARGUMENTS_LEFT_OUT);
229
- items[i] = { ...item, arguments: ARGUMENTS_LEFT_OUT };
230
- }
231
- }
232
- return items;
233
- },
234
- };
235
- }