@moxxy/sdk 0.1.2 → 0.1.3
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.
- package/README.md +73 -73
- package/dist/compactor-helpers.d.ts +4 -1
- package/dist/compactor-helpers.d.ts.map +1 -1
- package/dist/compactor-helpers.js +50 -21
- package/dist/compactor-helpers.js.map +1 -1
- package/dist/define.d.ts +4 -0
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +6 -0
- package/dist/define.js.map +1 -1
- package/dist/embedding.d.ts +17 -0
- package/dist/embedding.d.ts.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/fs-utils.d.ts +27 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +44 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/http-utils.d.ts +16 -0
- package/dist/http-utils.d.ts.map +1 -0
- package/dist/http-utils.js +40 -0
- package/dist/http-utils.js.map +1 -0
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/mode-helpers.d.ts +58 -0
- package/dist/mode-helpers.d.ts.map +1 -1
- package/dist/mode-helpers.js +119 -0
- package/dist/mode-helpers.js.map +1 -1
- package/dist/mode.d.ts +8 -0
- package/dist/mode.d.ts.map +1 -1
- package/dist/mutex.d.ts +15 -0
- package/dist/mutex.d.ts.map +1 -0
- package/dist/mutex.js +15 -0
- package/dist/mutex.js.map +1 -0
- package/dist/plugin.d.ts +27 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/provider-utils.d.ts +6 -0
- package/dist/provider-utils.d.ts.map +1 -1
- package/dist/provider-utils.js +8 -0
- package/dist/provider-utils.js.map +1 -1
- package/dist/resolvers.d.ts +52 -0
- package/dist/resolvers.d.ts.map +1 -0
- package/dist/resolvers.js +123 -0
- package/dist/resolvers.js.map +1 -0
- package/dist/schemas.d.ts +24 -24
- package/dist/session-like.d.ts +85 -1
- package/dist/session-like.d.ts.map +1 -1
- package/dist/voice.d.ts +36 -0
- package/dist/voice.d.ts.map +1 -0
- package/dist/voice.js +82 -0
- package/dist/voice.js.map +1 -0
- package/dist/workflow.d.ts +144 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +14 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +14 -14
- package/src/compactor-helpers.test.ts +41 -0
- package/src/compactor-helpers.ts +53 -19
- package/src/define.ts +10 -0
- package/src/embedding.ts +18 -0
- package/src/errors.ts +3 -0
- package/src/fs-utils.test.ts +61 -0
- package/src/fs-utils.ts +55 -0
- package/src/http-utils.test.ts +36 -0
- package/src/http-utils.ts +40 -0
- package/src/index.ts +58 -3
- package/src/mode-helpers.ts +169 -0
- package/src/mode.ts +8 -0
- package/src/mutex.test.ts +36 -0
- package/src/mutex.ts +31 -0
- package/src/plugin.ts +27 -1
- package/src/provider-utils.ts +9 -0
- package/src/resolvers.test.ts +45 -0
- package/src/resolvers.ts +164 -0
- package/src/session-like.ts +87 -1
- package/src/stuck-loop.test.ts +42 -0
- package/src/voice.ts +103 -0
- package/src/workflow.ts +165 -0
- package/dist/command-sync.d.ts +0 -23
- package/dist/command-sync.d.ts.map +0 -1
- package/dist/command-sync.js +0 -36
- package/dist/command-sync.js.map +0 -1
- package/dist/loop-helpers.d.ts +0 -68
- package/dist/loop-helpers.d.ts.map +0 -1
- package/dist/loop-helpers.js +0 -283
- package/dist/loop-helpers.js.map +0 -1
- package/dist/loop.d.ts +0 -106
- package/dist/loop.d.ts.map +0 -1
- package/dist/loop.js +0 -2
- package/dist/loop.js.map +0 -1
- package/dist/plugin-kind.d.ts +0 -10
- package/dist/plugin-kind.d.ts.map +0 -1
- package/dist/plugin-kind.js +0 -31
- package/dist/plugin-kind.js.map +0 -1
package/dist/loop-helpers.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ProviderMessage } from './provider.js';
|
|
2
|
-
import type { LoopContext } from './loop.js';
|
|
3
|
-
import type { StopReason } from './provider-utils.js';
|
|
4
|
-
import type { Skill } from './skill.js';
|
|
5
|
-
/**
|
|
6
|
-
* Shared bits used by every loop strategy: a typed tool-use struct and a
|
|
7
|
-
* common stream-collection helper that runs `onBeforeProviderCall` hooks
|
|
8
|
-
* and reduces a provider stream down to `{text, toolUses, stopReason}`.
|
|
9
|
-
*
|
|
10
|
-
* Lives in core (not in each loop package) so a new loop strategy stays
|
|
11
|
-
* consistent — and so behavioral fixes here propagate. Previously
|
|
12
|
-
* loop-plan-execute had its own copy that skipped the hook (audit bug).
|
|
13
|
-
*/
|
|
14
|
-
export interface CollectedToolUse {
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly input: unknown;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Compose a model-facing system prompt that includes any base prompt
|
|
21
|
-
* plus a COMPACT skill index (name + description + triggers only).
|
|
22
|
-
*
|
|
23
|
-
* Lazy-loading design: the body is intentionally NOT inlined. The model
|
|
24
|
-
* matches user intent against the description/triggers, then calls the
|
|
25
|
-
* `load_skill` tool to fetch the body of the skill it picked. This keeps
|
|
26
|
-
* the system prompt small even with many skills installed and avoids
|
|
27
|
-
* paying for skill bodies the model never actually follows.
|
|
28
|
-
*/
|
|
29
|
-
export declare function buildSystemPromptWithSkills(baseSystemPrompt: string | undefined, skills: ReadonlyArray<Skill>): string | undefined;
|
|
30
|
-
export interface ProjectMessagesOptions {
|
|
31
|
-
/** Optional system prompt; emitted as the first message when set. */
|
|
32
|
-
readonly systemPrompt?: string;
|
|
33
|
-
/** Optional trailing user message — useful for plan-execute's "Focus on this step now: X". */
|
|
34
|
-
readonly trailingUserText?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Project the session's event log to a flat list of ProviderMessages
|
|
38
|
-
* suitable for handing to `provider.stream`. Used by every loop strategy.
|
|
39
|
-
*
|
|
40
|
-
* Handles user_prompt, assistant_message, tool_call_requested (grouped
|
|
41
|
-
* into a single assistant message of tool_use blocks), and tool_result.
|
|
42
|
-
* Other event types are passed through as a no-op.
|
|
43
|
-
*
|
|
44
|
-
* Note: this is the minimal projection used by loop strategies. Core's
|
|
45
|
-
* `selectMessages` is a richer variant that also honors compaction events
|
|
46
|
-
* and attachments; the simpler form here lives in the SDK so loop plugins
|
|
47
|
-
* stay independent of core.
|
|
48
|
-
*/
|
|
49
|
-
export declare function projectMessagesFromLog(ctx: Pick<LoopContext, 'log'>, opts?: ProjectMessagesOptions): ProviderMessage[];
|
|
50
|
-
export interface StreamResult {
|
|
51
|
-
readonly text: string;
|
|
52
|
-
readonly toolUses: ReadonlyArray<CollectedToolUse>;
|
|
53
|
-
readonly stopReason: StopReason;
|
|
54
|
-
readonly error: {
|
|
55
|
-
readonly message: string;
|
|
56
|
-
readonly retryable: boolean;
|
|
57
|
-
} | null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Pulls a provider stream, emits `assistant_chunk` events for text deltas,
|
|
61
|
-
* collects tool_use blocks, and returns the final `{text, toolUses, stopReason}`.
|
|
62
|
-
* Runs `onBeforeProviderCall` lifecycle hooks before the call.
|
|
63
|
-
*/
|
|
64
|
-
export declare function collectProviderStream(ctx: LoopContext, messages: ReadonlyArray<ProviderMessage>, opts?: {
|
|
65
|
-
iteration?: number;
|
|
66
|
-
includeTools?: boolean;
|
|
67
|
-
}): Promise<StreamResult>;
|
|
68
|
-
//# sourceMappingURL=loop-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop-helpers.d.ts","sourceRoot":"","sources":["../src/loop-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,eAAe,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,M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EAAE,OAAO,CAAA;CAAO,GACxD,OAAO,CAAC,YAAY,CAAC,CAoFvB"}
|
package/dist/loop-helpers.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compose a model-facing system prompt that includes any base prompt
|
|
3
|
-
* plus a COMPACT skill index (name + description + triggers only).
|
|
4
|
-
*
|
|
5
|
-
* Lazy-loading design: the body is intentionally NOT inlined. The model
|
|
6
|
-
* matches user intent against the description/triggers, then calls the
|
|
7
|
-
* `load_skill` tool to fetch the body of the skill it picked. This keeps
|
|
8
|
-
* the system prompt small even with many skills installed and avoids
|
|
9
|
-
* paying for skill bodies the model never actually follows.
|
|
10
|
-
*/
|
|
11
|
-
export function buildSystemPromptWithSkills(baseSystemPrompt, skills) {
|
|
12
|
-
if (skills.length === 0)
|
|
13
|
-
return baseSystemPrompt;
|
|
14
|
-
const header = `## Available skills\n\n` +
|
|
15
|
-
`Each line below is a pre-authored playbook for a specific intent. ` +
|
|
16
|
-
`When the user's request matches one of these (by name, description, ` +
|
|
17
|
-
`or triggers), call \`load_skill({ name: "<skill-name>" })\` FIRST to ` +
|
|
18
|
-
`fetch the full instructions, then follow them verbatim. Prefer using ` +
|
|
19
|
-
`a skill over re-deriving the workflow with ad-hoc tools.\n`;
|
|
20
|
-
const entries = skills
|
|
21
|
-
.map((s) => {
|
|
22
|
-
const fm = s.frontmatter;
|
|
23
|
-
const triggerHint = fm.triggers?.length
|
|
24
|
-
? ` (triggers: ${fm.triggers.map((t) => `"${t}"`).join(', ')})`
|
|
25
|
-
: '';
|
|
26
|
-
return `- **${fm.name}** — ${fm.description}${triggerHint}`;
|
|
27
|
-
})
|
|
28
|
-
.join('\n');
|
|
29
|
-
const skillBlock = `${header}\n${entries}`;
|
|
30
|
-
return baseSystemPrompt ? `${baseSystemPrompt}\n\n${skillBlock}` : skillBlock;
|
|
31
|
-
}
|
|
32
|
-
function activeCompactionRanges(events) {
|
|
33
|
-
return events
|
|
34
|
-
.filter((event) => event.type === 'compaction' &&
|
|
35
|
-
event.tokensSaved > 0 &&
|
|
36
|
-
event.summary.trim().length > 0 &&
|
|
37
|
-
event.replacedRange[0] <= event.replacedRange[1])
|
|
38
|
-
.map((event) => ({
|
|
39
|
-
from: event.replacedRange[0],
|
|
40
|
-
to: event.replacedRange[1],
|
|
41
|
-
summary: event.summary,
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
function eventInCompactionRange(seq, ranges) {
|
|
45
|
-
for (const range of ranges) {
|
|
46
|
-
if (seq >= range.from && seq <= range.to)
|
|
47
|
-
return range;
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Project the session's event log to a flat list of ProviderMessages
|
|
53
|
-
* suitable for handing to `provider.stream`. Used by every loop strategy.
|
|
54
|
-
*
|
|
55
|
-
* Handles user_prompt, assistant_message, tool_call_requested (grouped
|
|
56
|
-
* into a single assistant message of tool_use blocks), and tool_result.
|
|
57
|
-
* Other event types are passed through as a no-op.
|
|
58
|
-
*
|
|
59
|
-
* Note: this is the minimal projection used by loop strategies. Core's
|
|
60
|
-
* `selectMessages` is a richer variant that also honors compaction events
|
|
61
|
-
* and attachments; the simpler form here lives in the SDK so loop plugins
|
|
62
|
-
* stay independent of core.
|
|
63
|
-
*/
|
|
64
|
-
export function projectMessagesFromLog(ctx, opts = {}) {
|
|
65
|
-
const messages = [];
|
|
66
|
-
if (opts.systemPrompt) {
|
|
67
|
-
messages.push({ role: 'system', content: [{ type: 'text', text: opts.systemPrompt }] });
|
|
68
|
-
}
|
|
69
|
-
const allEvents = ctx.log.slice();
|
|
70
|
-
const compactions = activeCompactionRanges(allEvents);
|
|
71
|
-
const emittedCompactions = new Set();
|
|
72
|
-
// Pre-scan: build the set of callIds that have a matching tool_result
|
|
73
|
-
// (or tool_call_denied) somewhere in the log. Used to synthesize a
|
|
74
|
-
// fallback `[interrupted]` tool_result for orphan tool_use blocks
|
|
75
|
-
// when the assistant message gets flushed.
|
|
76
|
-
//
|
|
77
|
-
// Without this fallback the provider rejects the whole conversation
|
|
78
|
-
// with "assistant message with 'tool_calls' must be followed by tool
|
|
79
|
-
// messages responding to each 'tool_call_id'". Orphans typically
|
|
80
|
-
// appear after a cancelled turn, an aborted process, or a tool
|
|
81
|
-
// exception that bypassed the loop's tool_result emit path.
|
|
82
|
-
const resolvedCallIds = new Set();
|
|
83
|
-
for (const e of allEvents) {
|
|
84
|
-
if (e.type === 'tool_result' || e.type === 'tool_call_denied') {
|
|
85
|
-
resolvedCallIds.add(e.callId);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
let pendingAssistant = null;
|
|
89
|
-
const flush = () => {
|
|
90
|
-
if (!pendingAssistant)
|
|
91
|
-
return;
|
|
92
|
-
const flushed = pendingAssistant;
|
|
93
|
-
messages.push(flushed);
|
|
94
|
-
pendingAssistant = null;
|
|
95
|
-
// Synthesize fallback tool_result messages for any tool_use blocks
|
|
96
|
-
// whose callId never resolved in the event log. Has to land
|
|
97
|
-
// immediately after the assistant message (and before any
|
|
98
|
-
// subsequent user_prompt / assistant_message) so the provider sees
|
|
99
|
-
// a clean assistant→tool-result chain.
|
|
100
|
-
for (const block of flushed.content) {
|
|
101
|
-
if (block.type === 'tool_use' && !resolvedCallIds.has(block.id)) {
|
|
102
|
-
messages.push({
|
|
103
|
-
role: 'tool_result',
|
|
104
|
-
content: [
|
|
105
|
-
{
|
|
106
|
-
type: 'tool_result',
|
|
107
|
-
toolUseId: block.id,
|
|
108
|
-
content: '[tool call did not return a result — possibly interrupted or cancelled]',
|
|
109
|
-
isError: true,
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
});
|
|
113
|
-
// Mark synthesized so we don't double-emit if the same orphan
|
|
114
|
-
// appears in multiple groups (defensive — shouldn't normally
|
|
115
|
-
// happen since each tool_call_requested has a unique callId).
|
|
116
|
-
resolvedCallIds.add(block.id);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
for (const e of allEvents) {
|
|
121
|
-
const compaction = eventInCompactionRange(e.seq, compactions);
|
|
122
|
-
if (compaction) {
|
|
123
|
-
if (!emittedCompactions.has(compaction)) {
|
|
124
|
-
emittedCompactions.add(compaction);
|
|
125
|
-
flush();
|
|
126
|
-
messages.push({
|
|
127
|
-
role: 'user',
|
|
128
|
-
content: [{ type: 'text', text: `[summary of earlier turns]\n${compaction.summary}` }],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
switch (e.type) {
|
|
134
|
-
case 'user_prompt': {
|
|
135
|
-
flush();
|
|
136
|
-
const blocks = [{ type: 'text', text: e.text }];
|
|
137
|
-
if (e.attachments) {
|
|
138
|
-
for (const att of e.attachments) {
|
|
139
|
-
if (att.kind === 'image') {
|
|
140
|
-
blocks.push({
|
|
141
|
-
type: 'image',
|
|
142
|
-
mediaType: att.mediaType ?? 'image/png',
|
|
143
|
-
data: att.content,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
blocks.push({
|
|
148
|
-
type: 'text',
|
|
149
|
-
text: `[${att.kind}${att.name ? ` ${att.name}` : ''}]\n${att.content}`,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
messages.push({ role: 'user', content: blocks });
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case 'assistant_message':
|
|
158
|
-
flush();
|
|
159
|
-
messages.push({ role: 'assistant', content: [{ type: 'text', text: e.content }] });
|
|
160
|
-
break;
|
|
161
|
-
case 'tool_call_requested': {
|
|
162
|
-
pendingAssistant ??= { role: 'assistant', content: [] };
|
|
163
|
-
pendingAssistant.content.push({
|
|
164
|
-
type: 'tool_use',
|
|
165
|
-
id: e.callId,
|
|
166
|
-
name: e.name,
|
|
167
|
-
input: e.input,
|
|
168
|
-
});
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
case 'tool_result': {
|
|
172
|
-
flush();
|
|
173
|
-
const text = e.error
|
|
174
|
-
? `[error:${e.error.kind}] ${e.error.message}`
|
|
175
|
-
: typeof e.output === 'string'
|
|
176
|
-
? e.output
|
|
177
|
-
: JSON.stringify(e.output ?? '');
|
|
178
|
-
messages.push({
|
|
179
|
-
role: 'tool_result',
|
|
180
|
-
content: [{ type: 'tool_result', toolUseId: e.callId, content: text, isError: !e.ok }],
|
|
181
|
-
});
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
default:
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
flush();
|
|
189
|
-
if (opts.trailingUserText) {
|
|
190
|
-
messages.push({ role: 'user', content: [{ type: 'text', text: opts.trailingUserText }] });
|
|
191
|
-
}
|
|
192
|
-
return messages;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Pulls a provider stream, emits `assistant_chunk` events for text deltas,
|
|
196
|
-
* collects tool_use blocks, and returns the final `{text, toolUses, stopReason}`.
|
|
197
|
-
* Runs `onBeforeProviderCall` lifecycle hooks before the call.
|
|
198
|
-
*/
|
|
199
|
-
export async function collectProviderStream(ctx, messages, opts = {}) {
|
|
200
|
-
const req = {
|
|
201
|
-
model: ctx.model,
|
|
202
|
-
system: ctx.systemPrompt,
|
|
203
|
-
messages,
|
|
204
|
-
...(opts.includeTools === false ? {} : { tools: ctx.tools.list() }),
|
|
205
|
-
signal: ctx.signal,
|
|
206
|
-
};
|
|
207
|
-
const transformed = await ctx.hooks.dispatchBeforeProviderCall(req, {
|
|
208
|
-
sessionId: ctx.sessionId,
|
|
209
|
-
cwd: '',
|
|
210
|
-
log: ctx.log,
|
|
211
|
-
env: {},
|
|
212
|
-
turnId: ctx.turnId,
|
|
213
|
-
iteration: opts.iteration ?? 0,
|
|
214
|
-
});
|
|
215
|
-
let text = '';
|
|
216
|
-
const toolUses = new Map();
|
|
217
|
-
let stopReason = 'end_turn';
|
|
218
|
-
let error = null;
|
|
219
|
-
let stream;
|
|
220
|
-
try {
|
|
221
|
-
stream = ctx.provider.stream(transformed);
|
|
222
|
-
}
|
|
223
|
-
catch (err) {
|
|
224
|
-
return {
|
|
225
|
-
text: '',
|
|
226
|
-
toolUses: [],
|
|
227
|
-
stopReason: 'error',
|
|
228
|
-
error: { message: err instanceof Error ? err.message : String(err), retryable: false },
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
for await (const event of stream) {
|
|
233
|
-
switch (event.type) {
|
|
234
|
-
case 'text_delta': {
|
|
235
|
-
text += event.delta;
|
|
236
|
-
await ctx.emit({
|
|
237
|
-
type: 'assistant_chunk',
|
|
238
|
-
sessionId: ctx.sessionId,
|
|
239
|
-
turnId: ctx.turnId,
|
|
240
|
-
source: 'model',
|
|
241
|
-
delta: event.delta,
|
|
242
|
-
});
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
case 'tool_use_start': {
|
|
246
|
-
toolUses.set(event.id, { name: event.name });
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case 'tool_use_end': {
|
|
250
|
-
const existing = toolUses.get(event.id) ?? {};
|
|
251
|
-
toolUses.set(event.id, { ...existing, input: event.input });
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
case 'message_end': {
|
|
255
|
-
stopReason = event.stopReason;
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
case 'error': {
|
|
259
|
-
error = { message: event.message, retryable: event.retryable };
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
case 'message_start':
|
|
263
|
-
case 'tool_use_delta':
|
|
264
|
-
default:
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
catch (err) {
|
|
270
|
-
error = {
|
|
271
|
-
message: err instanceof Error ? err.message : String(err),
|
|
272
|
-
retryable: false,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
const finalToolUses = [];
|
|
276
|
-
for (const [id, partial] of toolUses) {
|
|
277
|
-
if (!partial.name)
|
|
278
|
-
continue;
|
|
279
|
-
finalToolUses.push({ id, name: partial.name, input: partial.input ?? {} });
|
|
280
|
-
}
|
|
281
|
-
return { text, toolUses: finalToolUses, stopReason, error };
|
|
282
|
-
}
|
|
283
|
-
//# sourceMappingURL=loop-helpers.js.map
|
package/dist/loop-helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop-helpers.js","sourceRoot":"","sources":["../src/loop-helpers.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,gBAAoC,EACpC,MAA4B;IAE5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC;IACjD,MAAM,MAAM,GACV,yBAAyB;QACzB,oEAAoE;QACpE,sEAAsE;QACtE,uEAAuE;QACvE,uEAAuE;QACvE,4DAA4D,CAAC;IAC/D,MAAM,OAAO,GAAG,MAAM;SACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC;QACzB,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM;YACrC,CAAC,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC/D,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,OAAO,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC,WAAW,GAAG,WAAW,EAAE,CAAC;IAC9D,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,UAAU,GAAG,GAAG,MAAM,KAAK,OAAO,EAAE,CAAC;IAC3C,OAAO,gBAAgB,CAAC,CAAC,CAAC,GAAG,gBAAgB,OAAO,UAA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SAAS;QAC5B,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC9D,CAAC"}
|
package/dist/loop.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { CompactorDef } from './compactor.js';
|
|
2
|
-
import type { EmittedEvent, MoxxyEvent } from './events.js';
|
|
3
|
-
import type { HookDispatcher } from './hooks.js';
|
|
4
|
-
import type { SessionId, TurnId } from './ids.js';
|
|
5
|
-
import type { EventLogReader } from './log.js';
|
|
6
|
-
import type { PermissionResolver } from './permission.js';
|
|
7
|
-
import type { LLMProvider } from './provider.js';
|
|
8
|
-
import type { Skill } from './skill.js';
|
|
9
|
-
import type { SubagentSpawner } from './subagent.js';
|
|
10
|
-
import type { ToolDef } from './tool.js';
|
|
11
|
-
export interface ToolRegistry {
|
|
12
|
-
list(): ReadonlyArray<ToolDef>;
|
|
13
|
-
get(name: string): ToolDef | undefined;
|
|
14
|
-
execute(name: string, input: unknown, signal: AbortSignal, opts?: ToolExecuteOpts): Promise<unknown>;
|
|
15
|
-
}
|
|
16
|
-
export interface ToolExecuteOpts {
|
|
17
|
-
readonly callId?: string;
|
|
18
|
-
readonly sessionId?: string;
|
|
19
|
-
readonly turnId?: string;
|
|
20
|
-
readonly log?: EventLogReader;
|
|
21
|
-
readonly cwd?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface SkillRegistry {
|
|
24
|
-
list(): ReadonlyArray<Skill>;
|
|
25
|
-
get(id: string): Skill | undefined;
|
|
26
|
-
byName(name: string): Skill | undefined;
|
|
27
|
-
filterByTriggers(prompt: string): ReadonlyArray<Skill>;
|
|
28
|
-
}
|
|
29
|
-
export interface PluginHostHandle {
|
|
30
|
-
list(): ReadonlyArray<{
|
|
31
|
-
name: string;
|
|
32
|
-
version: string;
|
|
33
|
-
loaded: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
reload(): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
export interface LoopContext {
|
|
38
|
-
readonly sessionId: SessionId;
|
|
39
|
-
readonly turnId: TurnId;
|
|
40
|
-
readonly model: string;
|
|
41
|
-
readonly systemPrompt?: string;
|
|
42
|
-
readonly provider: LLMProvider;
|
|
43
|
-
readonly tools: ToolRegistry;
|
|
44
|
-
readonly skills: SkillRegistry;
|
|
45
|
-
readonly log: EventLogReader;
|
|
46
|
-
readonly compactor: CompactorDef | null;
|
|
47
|
-
readonly permissions: PermissionResolver;
|
|
48
|
-
/**
|
|
49
|
-
* Optional generic "ask the user a question" gate. Any loop strategy can
|
|
50
|
-
* call this to surface a checkpoint to the user — plan-execute uses it
|
|
51
|
-
* after producing a plan, but a code-execution loop could use it for
|
|
52
|
-
* "run this command?" or a refactor loop for "apply this diff?". When
|
|
53
|
-
* absent (headless / non-TTY), strategies should proceed as if the user
|
|
54
|
-
* picked the default option, or fail closed depending on the strategy.
|
|
55
|
-
*/
|
|
56
|
-
readonly approval?: ApprovalResolver;
|
|
57
|
-
readonly hooks: HookDispatcher;
|
|
58
|
-
readonly pluginHost: PluginHostHandle;
|
|
59
|
-
readonly signal: AbortSignal;
|
|
60
|
-
readonly maxIterations?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Spawn one or more child agents that share the parent's registries
|
|
63
|
-
* but run in isolation. Children stream their events back to the
|
|
64
|
-
* parent log as `plugin_event` records with `subagent_*` subtypes.
|
|
65
|
-
* Absent in synthetic test contexts that don't model a full Session.
|
|
66
|
-
*/
|
|
67
|
-
readonly subagents?: SubagentSpawner;
|
|
68
|
-
emit(event: EmittedEvent): Promise<MoxxyEvent>;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Generic approval-dialog request. The TUI renders `title` as the header,
|
|
72
|
-
* `body` as a verbatim block (plan text, diff, command preview, etc.), and
|
|
73
|
-
* a single-select list of `options`. An option may set `requestsText` so
|
|
74
|
-
* the dialog prompts for follow-up text after selection (e.g. redraft
|
|
75
|
-
* feedback). `kind` is a loose tag the dialog/CLI can use for styling.
|
|
76
|
-
*/
|
|
77
|
-
export interface ApprovalRequest {
|
|
78
|
-
readonly title: string;
|
|
79
|
-
readonly body: string;
|
|
80
|
-
readonly options: ReadonlyArray<ApprovalOption>;
|
|
81
|
-
readonly defaultOptionId?: string;
|
|
82
|
-
readonly kind?: string;
|
|
83
|
-
}
|
|
84
|
-
export interface ApprovalOption {
|
|
85
|
-
readonly id: string;
|
|
86
|
-
readonly label: string;
|
|
87
|
-
readonly hotkey?: string;
|
|
88
|
-
readonly description?: string;
|
|
89
|
-
readonly requestsText?: boolean;
|
|
90
|
-
readonly textPrompt?: string;
|
|
91
|
-
readonly danger?: boolean;
|
|
92
|
-
}
|
|
93
|
-
export interface ApprovalDecision {
|
|
94
|
-
readonly optionId: string;
|
|
95
|
-
/** Free-text follow-up the user typed when the option had `requestsText: true`. */
|
|
96
|
-
readonly text?: string;
|
|
97
|
-
}
|
|
98
|
-
export interface ApprovalResolver {
|
|
99
|
-
readonly name: string;
|
|
100
|
-
confirm(req: ApprovalRequest): Promise<ApprovalDecision>;
|
|
101
|
-
}
|
|
102
|
-
export interface LoopStrategyDef {
|
|
103
|
-
readonly name: string;
|
|
104
|
-
run(ctx: LoopContext): AsyncIterable<MoxxyEvent>;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=loop.d.ts.map
|
package/dist/loop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC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 +0,0 @@
|
|
|
1
|
-
export declare const PLUGIN_KINDS: readonly ["tools", "provider", "mode", "compactor", "cache-strategy", "view-renderer", "tunnel-provider", "mcp", "cli", "channel", "hooks", "agent", "command", "transcriber", "ui"];
|
|
2
|
-
export type PluginKind = (typeof PLUGIN_KINDS)[number];
|
|
3
|
-
export interface PluginKindCarrier {
|
|
4
|
-
readonly kind?: PluginKind | ReadonlyArray<PluginKind>;
|
|
5
|
-
}
|
|
6
|
-
export declare function pluginKindList(kind: PluginKindCarrier['kind']): ReadonlyArray<PluginKind>;
|
|
7
|
-
export declare function isPureUiPluginManifest(manifest: PluginKindCarrier): boolean;
|
|
8
|
-
/** True when the manifest declares `kind: 'ui'` (alone or alongside others). */
|
|
9
|
-
export declare function isUiPluginManifest(manifest: PluginKindCarrier): boolean;
|
|
10
|
-
//# sourceMappingURL=plugin-kind.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kind.d.ts","sourceRoot":"","sources":["../src/plugin-kind.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,sLAgBf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;CACxD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAGzF;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAG3E;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAEvE"}
|
package/dist/plugin-kind.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const PLUGIN_KINDS = [
|
|
2
|
-
'tools',
|
|
3
|
-
'provider',
|
|
4
|
-
'mode',
|
|
5
|
-
'compactor',
|
|
6
|
-
'cache-strategy',
|
|
7
|
-
'view-renderer',
|
|
8
|
-
'tunnel-provider',
|
|
9
|
-
'mcp',
|
|
10
|
-
'cli',
|
|
11
|
-
'channel',
|
|
12
|
-
'hooks',
|
|
13
|
-
'agent',
|
|
14
|
-
'command',
|
|
15
|
-
'transcriber',
|
|
16
|
-
'ui',
|
|
17
|
-
];
|
|
18
|
-
export function pluginKindList(kind) {
|
|
19
|
-
if (!kind)
|
|
20
|
-
return [];
|
|
21
|
-
return typeof kind === 'string' ? [kind] : kind;
|
|
22
|
-
}
|
|
23
|
-
export function isPureUiPluginManifest(manifest) {
|
|
24
|
-
const kinds = pluginKindList(manifest.kind);
|
|
25
|
-
return kinds.length === 1 && kinds[0] === 'ui';
|
|
26
|
-
}
|
|
27
|
-
/** True when the manifest declares `kind: 'ui'` (alone or alongside others). */
|
|
28
|
-
export function isUiPluginManifest(manifest) {
|
|
29
|
-
return pluginKindList(manifest.kind).includes('ui');
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=plugin-kind.js.map
|
package/dist/plugin-kind.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kind.js","sourceRoot":"","sources":["../src/plugin-kind.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO;IACP,UAAU;IACV,MAAM;IACN,WAAW;IACX,gBAAgB;IAChB,eAAe;IACf,iBAAiB;IACjB,KAAK;IACL,KAAK;IACL,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,aAAa;IACb,IAAI;CACI,CAAC;AAQX,MAAM,UAAU,cAAc,CAAC,IAA+B;IAC5D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAA2B;IAChE,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AACjD,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,QAA2B;IAC5D,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|