@rebon/cli-darwin-arm64 0.17.2 → 0.18.0

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 (82) hide show
  1. package/bin/compose-runtime/package.json +17 -0
  2. package/bin/compose-runtime/payload/compose/credentials-runtime.js +38 -0
  3. package/bin/compose-runtime/payload/compose/llm-runtime.js +330 -0
  4. package/bin/compose-runtime/payload/compose/loop-assembly.js +149 -0
  5. package/bin/compose-runtime/payload/compose/serve-dispatch.js +82 -0
  6. package/bin/compose-runtime/payload/compose/shims/dsh-anonymous-user-id.js +10 -0
  7. package/bin/compose-runtime/payload/compose/shims/dsh-credentials.js +13 -0
  8. package/bin/compose-runtime/payload/compose/shims/dsh-launch-environment.js +21 -0
  9. package/bin/compose-runtime/payload/compose/shims/dsh-llm.js +313 -0
  10. package/bin/compose-runtime/payload/compose/shims/dsh-settings.js +43 -0
  11. package/bin/compose-runtime/payload/compose/shims/dsh-tools.js +20 -0
  12. package/bin/compose-runtime/payload/compose/shims/dsh-web.js +10 -0
  13. package/bin/compose-runtime/payload/compose/shims/llm-adapter.js +32 -0
  14. package/bin/compose-runtime/payload/compose/shims/zod-lite.js +49 -0
  15. package/bin/compose-runtime/payload/compose/systemprompt-runtime.js +74 -0
  16. package/bin/compose-runtime/payload/compose/tools-runtime.js +228 -0
  17. package/bin/compose-runtime/payload/compose/web-runtime.js +204 -0
  18. package/bin/compose-runtime/payload/vendor/cordis/index.js +1530 -0
  19. package/bin/compose-runtime/payload/vendor/cosmokit/LICENSE +21 -0
  20. package/bin/compose-runtime/payload/vendor/cosmokit/index.mjs +357 -0
  21. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-agent +21 -0
  22. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-agent-loop +21 -0
  23. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-llm-core +21 -0
  24. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-llm-deepseek +21 -0
  25. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-logger-console +21 -0
  26. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-scope +21 -0
  27. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-session +21 -0
  28. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-system-prompt +21 -0
  29. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-timeout +21 -0
  30. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-timer +21 -0
  31. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-tool-todo +21 -0
  32. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-tool-web +21 -0
  33. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-tools-schema +21 -0
  34. package/bin/compose-runtime/payload/vendor/dsh/LICENSE-web-search-exa +21 -0
  35. package/bin/compose-runtime/payload/vendor/dsh/agent-loop.js +1193 -0
  36. package/bin/compose-runtime/payload/vendor/dsh/agent.js +714 -0
  37. package/bin/compose-runtime/payload/vendor/dsh/llm-core.js +269 -0
  38. package/bin/compose-runtime/payload/vendor/dsh/llm-deepseek.js +672 -0
  39. package/bin/compose-runtime/payload/vendor/dsh/logger-console.js +83 -0
  40. package/bin/compose-runtime/payload/vendor/dsh/scope.js +287 -0
  41. package/bin/compose-runtime/payload/vendor/dsh/session.js +1668 -0
  42. package/bin/compose-runtime/payload/vendor/dsh/system-prompt.js +309 -0
  43. package/bin/compose-runtime/payload/vendor/dsh/timeout.js +100 -0
  44. package/bin/compose-runtime/payload/vendor/dsh/timer.js +128 -0
  45. package/bin/compose-runtime/payload/vendor/dsh/tool-todo.js +143 -0
  46. package/bin/compose-runtime/payload/vendor/dsh/tool-web.js +1527 -0
  47. package/bin/compose-runtime/payload/vendor/dsh/tools-schema.js +849 -0
  48. package/bin/compose-runtime/payload/vendor/dsh/web-search-exa.js +122 -0
  49. package/bin/compose-runtime/payload/vendor/eventsource-parser/LICENSE +21 -0
  50. package/bin/compose-runtime/payload/vendor/eventsource-parser/index.js +177 -0
  51. package/bin/compose-runtime/payload/vendor/eventsource-parser/stream.js +48 -0
  52. package/bin/compose-runtime/payload/vendor/schemastery/index.mjs +656 -0
  53. package/bin/compose-runtime/payload-manifests.json +48 -0
  54. package/bin/compose-runtime/src/bridge.mjs +142 -0
  55. package/bin/compose-runtime/src/credentials-runtime.mjs +50 -0
  56. package/bin/compose-runtime/src/eventsource-stream.mjs +48 -0
  57. package/bin/compose-runtime/src/index.mjs +7 -0
  58. package/bin/compose-runtime/src/llm-runtime.mjs +326 -0
  59. package/bin/compose-runtime/src/loader.mjs +78 -0
  60. package/bin/compose-runtime/src/loop-assembly.mjs +237 -0
  61. package/bin/compose-runtime/src/payload.mjs +49 -0
  62. package/bin/compose-runtime/src/plugin.mjs +59 -0
  63. package/bin/compose-runtime/src/realm.mjs +223 -0
  64. package/bin/compose-runtime/src/registry.mjs +191 -0
  65. package/bin/compose-runtime/src/resolve.mjs +115 -0
  66. package/bin/compose-runtime/src/systemprompt-runtime.mjs +67 -0
  67. package/bin/compose-runtime/src/tools-runtime.mjs +239 -0
  68. package/bin/compose-runtime/src/web-runtime.mjs +209 -0
  69. package/bin/plugin-host/package.json +11 -0
  70. package/bin/plugin-host/src/bridge.mjs +64 -0
  71. package/bin/plugin-host/src/cli.mjs +105 -0
  72. package/bin/plugin-host/src/framing.mjs +113 -0
  73. package/bin/plugin-host/src/host.mjs +624 -0
  74. package/bin/plugin-host/src/json.mjs +196 -0
  75. package/bin/plugin-host/src/lifecycle.mjs +114 -0
  76. package/bin/plugin-host/src/loader.mjs +142 -0
  77. package/bin/plugin-host/src/methods.mjs +256 -0
  78. package/bin/plugin-host/src/protocol.mjs +129 -0
  79. package/bin/plugin-host/src/sdk.mjs +7 -0
  80. package/bin/rebon +0 -0
  81. package/bin/rebon-boa-helper +0 -0
  82. package/package.json +4 -1
@@ -0,0 +1,269 @@
1
+ // packages/llm/llm/src/brand.ts
2
+ function MessageId(id) {
3
+ return id;
4
+ }
5
+ function CallId(id) {
6
+ return id;
7
+ }
8
+
9
+ // packages/llm/llm/src/never.ts
10
+ function assertNever(value, context) {
11
+ const rendered = JSON.stringify(value) ?? String(value);
12
+ throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
13
+ }
14
+
15
+ // packages/llm/llm/src/call-config.ts
16
+ var AGENT_LOOP_REQUESTS = /* @__PURE__ */ new WeakSet();
17
+ function callConfigEquals(a, b) {
18
+ if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens) return false;
19
+ if (a.stop === void 0 || b.stop === void 0) return a.stop === b.stop;
20
+ return a.stop.length === b.stop.length && a.stop.every((s, i) => s === b.stop?.[i]);
21
+ }
22
+ function markAgentLoopRequest(request) {
23
+ AGENT_LOOP_REQUESTS.add(request);
24
+ return request;
25
+ }
26
+ function isAgentLoopRequest(request) {
27
+ return AGENT_LOOP_REQUESTS.has(request);
28
+ }
29
+ function deepFreeze(value) {
30
+ const seen = /* @__PURE__ */ new WeakSet();
31
+ const pending = [{ kind: "visit", node: value }];
32
+ while (pending.length > 0) {
33
+ const task = pending.pop();
34
+ if (task === void 0) continue;
35
+ if (task.kind === "property") {
36
+ pending.push({ kind: "visit", node: task.source[task.key] });
37
+ continue;
38
+ }
39
+ const node = task.node;
40
+ if (node === null || typeof node !== "object") continue;
41
+ if (node instanceof AbortSignal) continue;
42
+ if (seen.has(node)) continue;
43
+ seen.add(node);
44
+ Object.freeze(node);
45
+ const keys = Object.keys(node);
46
+ for (let index = keys.length - 1; index >= 0; index--) {
47
+ const key = keys[index];
48
+ if (key === void 0) continue;
49
+ pending.push({ kind: "property", source: node, key });
50
+ }
51
+ }
52
+ return value;
53
+ }
54
+
55
+ // packages/llm/llm/src/message.ts
56
+ function freezeMessage(message) {
57
+ return deepFreeze(structuredClone(message));
58
+ }
59
+ function createMessage(input) {
60
+ return freezeMessage({
61
+ ...input,
62
+ id: MessageId(crypto.randomUUID())
63
+ });
64
+ }
65
+ function createUserMessage(input) {
66
+ return createMessage({
67
+ ...input,
68
+ role: "user"
69
+ });
70
+ }
71
+ function createAssistantMessage(input) {
72
+ return createMessage({
73
+ role: "assistant",
74
+ content: input.content,
75
+ source: {
76
+ kind: "model",
77
+ ...input.source
78
+ }
79
+ });
80
+ }
81
+ function createToolResultMessage(input) {
82
+ return createUserMessage({
83
+ source: { kind: "tool", callId: input.callId },
84
+ content: [{
85
+ type: "tool-result",
86
+ toolCallId: input.callId,
87
+ content: input.content,
88
+ isError: input.isError
89
+ }]
90
+ });
91
+ }
92
+
93
+ // packages/llm/llm/src/assembler.ts
94
+ var BlockAssembler = class {
95
+ partials = /* @__PURE__ */ new Map();
96
+ order = [];
97
+ _usage;
98
+ _finish;
99
+ _replayState = void 0;
100
+ /**
101
+ * Feed one chunk into the assembly state.
102
+ * @param chunk - the next raw chunk, in stream order.
103
+ */
104
+ push(chunk) {
105
+ switch (chunk.type) {
106
+ case "block-start": {
107
+ if (!this.partials.has(chunk.index)) {
108
+ this.order.push(chunk.index);
109
+ this.partials.set(chunk.index, {
110
+ blockType: chunk.blockType,
111
+ text: "",
112
+ toolCallArguments: ""
113
+ });
114
+ }
115
+ return;
116
+ }
117
+ case "text-delta":
118
+ case "reasoning-delta": {
119
+ const partial = this.ensure(chunk.index, chunk.type === "text-delta" ? "text" : "reasoning");
120
+ if (partial.block) return;
121
+ partial.text += chunk.text;
122
+ return;
123
+ }
124
+ case "tool-call-delta": {
125
+ const partial = this.ensure(chunk.index, "tool-call");
126
+ if (partial.block) return;
127
+ partial.toolCallId = chunk.id;
128
+ if (chunk.name) partial.toolCallName = chunk.name;
129
+ partial.toolCallArguments += chunk.argumentsDelta;
130
+ return;
131
+ }
132
+ case "block-end": {
133
+ const partial = this.ensure(chunk.index, chunk.block.type);
134
+ if (partial.block) return;
135
+ partial.block = chunk.block;
136
+ return;
137
+ }
138
+ case "usage": {
139
+ this._usage = chunk.usage;
140
+ return;
141
+ }
142
+ case "finish": {
143
+ this._finish = chunk.reason;
144
+ this._replayState = chunk.replayState;
145
+ return;
146
+ }
147
+ default:
148
+ return assertNever(chunk, "BlockAssembler.push");
149
+ }
150
+ }
151
+ ensure(index, blockType) {
152
+ let partial = this.partials.get(index);
153
+ if (!partial) {
154
+ partial = { blockType, text: "", toolCallArguments: "" };
155
+ this.partials.set(index, partial);
156
+ this.order.push(index);
157
+ }
158
+ return partial;
159
+ }
160
+ assemble(partial, index) {
161
+ if (partial.block) return partial.block;
162
+ switch (partial.blockType) {
163
+ case "text":
164
+ return { type: "text", text: partial.text };
165
+ case "reasoning":
166
+ return { type: "reasoning", text: partial.text };
167
+ case "tool-call":
168
+ return {
169
+ type: "tool-call",
170
+ id: partial.toolCallId ?? CallId(`call-${index}`),
171
+ name: partial.toolCallName ?? "",
172
+ arguments: partial.toolCallArguments
173
+ };
174
+ default:
175
+ throw new Error(`cannot assemble incomplete block of type "${partial.blockType}"`);
176
+ }
177
+ }
178
+ /** Invariant accessor: every index in `order` has a partial. */
179
+ mustGet(index) {
180
+ const partial = this.partials.get(index);
181
+ if (!partial) throw new Error(`BlockAssembler invariant violated: no partial for index ${index}`);
182
+ return partial;
183
+ }
184
+ /**
185
+ * Assemble all blocks seen so far, in stream order.
186
+ * @returns one block per seen index, except that max-token truncation drops
187
+ * tool calls that cannot be executed safely; an open block assembles from
188
+ * its accumulated deltas (an unknown block type never closed by `block-end` throws).
189
+ */
190
+ blocks() {
191
+ const blocks = this.order.map((index) => this.assemble(this.mustGet(index), index));
192
+ return this.finish.kind === "max-tokens" ? blocks.filter((block) => block.type !== "tool-call") : blocks;
193
+ }
194
+ /** Usage from the `usage` chunk; undefined until one arrives. */
195
+ get usage() {
196
+ return this._usage;
197
+ }
198
+ /** Finish reason from the `finish` chunk; `{kind: 'stop'}` when the stream ended without one. */
199
+ get finish() {
200
+ return this._finish ?? { kind: "stop" };
201
+ }
202
+ /** Adapter-private replay state from the terminal finish chunk, if any. */
203
+ get replayState() {
204
+ return this._replayState;
205
+ }
206
+ /**
207
+ * The assembled assistant message.
208
+ * @param source - producer attribution for the assembled message.
209
+ * @returns a frozen assistant-role message over `blocks()` (same open-block assembly rules).
210
+ */
211
+ message(source = { kind: "plugin", plugin: "dsh-llm/assembler" }) {
212
+ return createMessage({ role: "assistant", content: this.blocks(), source });
213
+ }
214
+ };
215
+
216
+ // packages/llm/llm/src/error.ts
217
+ var STRUCTURED_CONTEXT_OVERFLOW = new RegExp(
218
+ String.raw`(?:^|[^a-z0-9])context[\s_-](?:length|window)[\s_-]` + String.raw`(?:exceed(?:ed|s)?|overflow(?:ed)?|limit[\s_-]exceeded)(?:$|[^a-z0-9])`,
219
+ "i"
220
+ );
221
+ var TOO_LARGE_FOR_CONTEXT = new RegExp(
222
+ String.raw`\b(?:request|prompt|input|messages?)\s+(?:is\s+|are\s+)?` + String.raw`too\s+(?:large|long)\s+for\s+(?:(?:this|the)\s+)?` + String.raw`(?:model(?:'s)?\s+)?context(?:\s+window)?\b`,
223
+ "i"
224
+ );
225
+ var EXCEEDS_MODEL_CONTEXT = new RegExp(
226
+ String.raw`\b(?:input|prompt|request|messages?)\b.{0,40}` + String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}` + String.raw`\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`,
227
+ "i"
228
+ );
229
+ function errorChain(value) {
230
+ const path = /* @__PURE__ */ new Set();
231
+ const render = (current) => {
232
+ if (path.has(current)) return "<circular cause>";
233
+ path.add(current);
234
+ try {
235
+ if (!(current instanceof Error)) {
236
+ if (typeof current === "object" && current !== null) {
237
+ const descriptor = Object.getOwnPropertyDescriptor(current, "message");
238
+ if (descriptor !== void 0 && "value" in descriptor && typeof descriptor.value === "string") {
239
+ return descriptor.value;
240
+ }
241
+ }
242
+ return String(current);
243
+ }
244
+ const message = current.message === "" ? current.name : current.message;
245
+ const members = current instanceof AggregateError && current.errors.length > 0 ? ` [${current.errors.map(render).join("; ")}]` : "";
246
+ const causeText = current.cause === void 0 || current.cause === null ? "" : render(current.cause);
247
+ const cause = causeText === "" || causeText === message ? "" : `: ${causeText}`;
248
+ return `${message}${members}${cause}`;
249
+ } catch {
250
+ return "<unrenderable value>";
251
+ } finally {
252
+ path.delete(current);
253
+ }
254
+ };
255
+ return render(value);
256
+ }
257
+ export {
258
+ BlockAssembler,
259
+ callConfigEquals,
260
+ createAssistantMessage,
261
+ createMessage,
262
+ createToolResultMessage,
263
+ createUserMessage,
264
+ deepFreeze,
265
+ errorChain,
266
+ freezeMessage,
267
+ isAgentLoopRequest,
268
+ markAgentLoopRequest
269
+ };