@moxxy/sdk 0.1.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 (211) hide show
  1. package/dist/agent.d.ts +39 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +2 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/cache-strategy.d.ts +35 -0
  6. package/dist/cache-strategy.d.ts.map +1 -0
  7. package/dist/cache-strategy.js +2 -0
  8. package/dist/cache-strategy.js.map +1 -0
  9. package/dist/channel.d.ts +146 -0
  10. package/dist/channel.d.ts.map +1 -0
  11. package/dist/channel.js +2 -0
  12. package/dist/channel.js.map +1 -0
  13. package/dist/client-session.d.ts +83 -0
  14. package/dist/client-session.d.ts.map +1 -0
  15. package/dist/client-session.js +2 -0
  16. package/dist/client-session.js.map +1 -0
  17. package/dist/command.d.ts +90 -0
  18. package/dist/command.d.ts.map +1 -0
  19. package/dist/command.js +15 -0
  20. package/dist/command.js.map +1 -0
  21. package/dist/compactor-helpers.d.ts +34 -0
  22. package/dist/compactor-helpers.d.ts.map +1 -0
  23. package/dist/compactor-helpers.js +156 -0
  24. package/dist/compactor-helpers.js.map +1 -0
  25. package/dist/compactor.d.ts +20 -0
  26. package/dist/compactor.d.ts.map +1 -0
  27. package/dist/compactor.js +2 -0
  28. package/dist/compactor.js.map +1 -0
  29. package/dist/define.d.ts +51 -0
  30. package/dist/define.d.ts.map +1 -0
  31. package/dist/define.js +71 -0
  32. package/dist/define.js.map +1 -0
  33. package/dist/elision-helpers.d.ts +27 -0
  34. package/dist/elision-helpers.d.ts.map +1 -0
  35. package/dist/elision-helpers.js +109 -0
  36. package/dist/elision-helpers.js.map +1 -0
  37. package/dist/elision-state.d.ts +49 -0
  38. package/dist/elision-state.d.ts.map +1 -0
  39. package/dist/elision-state.js +144 -0
  40. package/dist/elision-state.js.map +1 -0
  41. package/dist/embedding-cache.d.ts +32 -0
  42. package/dist/embedding-cache.d.ts.map +1 -0
  43. package/dist/embedding-cache.js +0 -0
  44. package/dist/embedding-cache.js.map +1 -0
  45. package/dist/embedding.d.ts +21 -0
  46. package/dist/embedding.d.ts.map +1 -0
  47. package/dist/embedding.js +2 -0
  48. package/dist/embedding.js.map +1 -0
  49. package/dist/errors.d.ts +81 -0
  50. package/dist/errors.d.ts.map +1 -0
  51. package/dist/errors.js +241 -0
  52. package/dist/errors.js.map +1 -0
  53. package/dist/events.d.ts +193 -0
  54. package/dist/events.d.ts.map +1 -0
  55. package/dist/events.js +2 -0
  56. package/dist/events.js.map +1 -0
  57. package/dist/hooks.d.ts +52 -0
  58. package/dist/hooks.d.ts.map +1 -0
  59. package/dist/hooks.js +2 -0
  60. package/dist/hooks.js.map +1 -0
  61. package/dist/ids.d.ts +18 -0
  62. package/dist/ids.d.ts.map +1 -0
  63. package/dist/ids.js +7 -0
  64. package/dist/ids.js.map +1 -0
  65. package/dist/index.d.ts +45 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +18 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/install-hints.d.ts +26 -0
  70. package/dist/install-hints.d.ts.map +1 -0
  71. package/dist/install-hints.js +15 -0
  72. package/dist/install-hints.js.map +1 -0
  73. package/dist/isolation.d.ts +125 -0
  74. package/dist/isolation.d.ts.map +1 -0
  75. package/dist/isolation.js +11 -0
  76. package/dist/isolation.js.map +1 -0
  77. package/dist/log.d.ts +11 -0
  78. package/dist/log.d.ts.map +1 -0
  79. package/dist/log.js +2 -0
  80. package/dist/log.js.map +1 -0
  81. package/dist/mode-helpers.d.ts +99 -0
  82. package/dist/mode-helpers.d.ts.map +1 -0
  83. package/dist/mode-helpers.js +368 -0
  84. package/dist/mode-helpers.js.map +1 -0
  85. package/dist/mode.d.ts +133 -0
  86. package/dist/mode.d.ts.map +1 -0
  87. package/dist/mode.js +2 -0
  88. package/dist/mode.js.map +1 -0
  89. package/dist/permission.d.ts +35 -0
  90. package/dist/permission.d.ts.map +1 -0
  91. package/dist/permission.js +2 -0
  92. package/dist/permission.js.map +1 -0
  93. package/dist/plugin.d.ts +88 -0
  94. package/dist/plugin.d.ts.map +1 -0
  95. package/dist/plugin.js +2 -0
  96. package/dist/plugin.js.map +1 -0
  97. package/dist/provider-utils.d.ts +40 -0
  98. package/dist/provider-utils.d.ts.map +1 -0
  99. package/dist/provider-utils.js +163 -0
  100. package/dist/provider-utils.js.map +1 -0
  101. package/dist/provider.d.ts +219 -0
  102. package/dist/provider.d.ts.map +1 -0
  103. package/dist/provider.js +2 -0
  104. package/dist/provider.js.map +1 -0
  105. package/dist/requirements.d.ts +22 -0
  106. package/dist/requirements.d.ts.map +1 -0
  107. package/dist/requirements.js +2 -0
  108. package/dist/requirements.js.map +1 -0
  109. package/dist/schemas.d.ts +228 -0
  110. package/dist/schemas.d.ts.map +1 -0
  111. package/dist/schemas.js +88 -0
  112. package/dist/schemas.js.map +1 -0
  113. package/dist/session-like.d.ts +111 -0
  114. package/dist/session-like.d.ts.map +1 -0
  115. package/dist/session-like.js +2 -0
  116. package/dist/session-like.js.map +1 -0
  117. package/dist/skill.d.ts +30 -0
  118. package/dist/skill.d.ts.map +1 -0
  119. package/dist/skill.js +2 -0
  120. package/dist/skill.js.map +1 -0
  121. package/dist/subagent.d.ts +45 -0
  122. package/dist/subagent.d.ts.map +1 -0
  123. package/dist/subagent.js +11 -0
  124. package/dist/subagent.js.map +1 -0
  125. package/dist/token-accounting.d.ts +73 -0
  126. package/dist/token-accounting.d.ts.map +1 -0
  127. package/dist/token-accounting.js +129 -0
  128. package/dist/token-accounting.js.map +1 -0
  129. package/dist/tool-dispatch.d.ts +19 -0
  130. package/dist/tool-dispatch.d.ts.map +1 -0
  131. package/dist/tool-dispatch.js +118 -0
  132. package/dist/tool-dispatch.js.map +1 -0
  133. package/dist/tool-gating.d.ts +32 -0
  134. package/dist/tool-gating.d.ts.map +1 -0
  135. package/dist/tool-gating.js +83 -0
  136. package/dist/tool-gating.js.map +1 -0
  137. package/dist/tool.d.ts +166 -0
  138. package/dist/tool.d.ts.map +1 -0
  139. package/dist/tool.js +2 -0
  140. package/dist/tool.js.map +1 -0
  141. package/dist/transcriber.d.ts +64 -0
  142. package/dist/transcriber.d.ts.map +1 -0
  143. package/dist/transcriber.js +21 -0
  144. package/dist/transcriber.js.map +1 -0
  145. package/dist/tunnel.d.ts +25 -0
  146. package/dist/tunnel.d.ts.map +1 -0
  147. package/dist/tunnel.js +2 -0
  148. package/dist/tunnel.js.map +1 -0
  149. package/dist/type-contracts.d.ts +2 -0
  150. package/dist/type-contracts.d.ts.map +1 -0
  151. package/dist/type-contracts.js +4 -0
  152. package/dist/type-contracts.js.map +1 -0
  153. package/dist/types.test-d.d.ts +2 -0
  154. package/dist/types.test-d.d.ts.map +1 -0
  155. package/dist/types.test-d.js +22 -0
  156. package/dist/types.test-d.js.map +1 -0
  157. package/dist/view-renderer.d.ts +97 -0
  158. package/dist/view-renderer.d.ts.map +1 -0
  159. package/dist/view-renderer.js +72 -0
  160. package/dist/view-renderer.js.map +1 -0
  161. package/package.json +38 -0
  162. package/src/agent.ts +38 -0
  163. package/src/cache-strategy.ts +39 -0
  164. package/src/channel.ts +158 -0
  165. package/src/client-session.ts +88 -0
  166. package/src/command.ts +86 -0
  167. package/src/compactor-helpers.test.ts +206 -0
  168. package/src/compactor-helpers.ts +163 -0
  169. package/src/compactor.ts +20 -0
  170. package/src/define.test.ts +76 -0
  171. package/src/define.ts +113 -0
  172. package/src/elision-helpers.ts +143 -0
  173. package/src/elision-state.ts +170 -0
  174. package/src/embedding-cache.ts +0 -0
  175. package/src/embedding.ts +22 -0
  176. package/src/errors.test.ts +176 -0
  177. package/src/errors.ts +308 -0
  178. package/src/events.ts +250 -0
  179. package/src/hooks.ts +54 -0
  180. package/src/ids.ts +16 -0
  181. package/src/index.ts +304 -0
  182. package/src/install-hints.ts +43 -0
  183. package/src/isolation.ts +148 -0
  184. package/src/log.ts +11 -0
  185. package/src/loop-helpers.test.ts +78 -0
  186. package/src/mode-helpers.ts +483 -0
  187. package/src/mode.ts +139 -0
  188. package/src/package-root.test.ts +40 -0
  189. package/src/permission.ts +37 -0
  190. package/src/plugin.ts +92 -0
  191. package/src/provider-utils.test.ts +84 -0
  192. package/src/provider-utils.ts +171 -0
  193. package/src/provider.ts +195 -0
  194. package/src/requirements.ts +35 -0
  195. package/src/schemas.test.ts +106 -0
  196. package/src/schemas.ts +97 -0
  197. package/src/session-like.ts +118 -0
  198. package/src/skill.ts +34 -0
  199. package/src/subagent.ts +46 -0
  200. package/src/token-accounting.test.ts +93 -0
  201. package/src/token-accounting.ts +202 -0
  202. package/src/token-efficiency.test.ts +459 -0
  203. package/src/tool-dispatch.ts +137 -0
  204. package/src/tool-gating.ts +107 -0
  205. package/src/tool.ts +175 -0
  206. package/src/transcriber.ts +71 -0
  207. package/src/tunnel.ts +26 -0
  208. package/src/type-contracts.ts +4 -0
  209. package/src/types.test-d.ts +29 -0
  210. package/src/view-renderer.test.ts +90 -0
  211. package/src/view-renderer.ts +156 -0
@@ -0,0 +1,193 @@
1
+ import type { EventId, PluginId, SessionId, SkillId, ToolCallId, TurnId } from './ids.js';
2
+ export type EventSource = 'user' | 'model' | 'tool' | 'plugin' | 'system' | 'compactor';
3
+ export interface EventBase {
4
+ readonly id: EventId;
5
+ readonly seq: number;
6
+ readonly ts: number;
7
+ readonly sessionId: SessionId;
8
+ readonly turnId: TurnId;
9
+ readonly causationId?: EventId;
10
+ readonly source: EventSource;
11
+ }
12
+ export interface UserPromptAttachment {
13
+ readonly kind: 'stdin' | 'file' | 'image' | 'audio';
14
+ /**
15
+ * Inline payload. For images this is base64-encoded bytes; for audio it
16
+ * is either base64-encoded bytes (when the channel hands raw audio
17
+ * straight through to a model with `supportsAudio`) or the transcript
18
+ * (when the channel pre-transcribed via the session's Transcriber).
19
+ * Channels SHOULD set `name` to disambiguate the two; `mediaType` is
20
+ * required when carrying raw audio bytes.
21
+ */
22
+ readonly content: string;
23
+ /** Human-readable label, e.g. the file path, `image.png`, or `voice.ogg`. */
24
+ readonly name?: string;
25
+ /** MIME type — required for images and raw audio so providers translate correctly. */
26
+ readonly mediaType?: string;
27
+ }
28
+ export interface UserPromptEvent extends EventBase {
29
+ readonly type: 'user_prompt';
30
+ readonly text: string;
31
+ readonly attachments?: ReadonlyArray<UserPromptAttachment>;
32
+ }
33
+ export interface AssistantChunkEvent extends EventBase {
34
+ readonly type: 'assistant_chunk';
35
+ readonly delta: string;
36
+ }
37
+ export interface AssistantMessageEvent extends EventBase {
38
+ readonly type: 'assistant_message';
39
+ readonly content: string;
40
+ readonly stopReason: 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'error';
41
+ }
42
+ export interface ToolCallRequestedEvent extends EventBase {
43
+ readonly type: 'tool_call_requested';
44
+ readonly callId: ToolCallId;
45
+ readonly name: string;
46
+ readonly input: unknown;
47
+ readonly skillContext?: SkillId;
48
+ }
49
+ export interface ToolCallApprovedEvent extends EventBase {
50
+ readonly type: 'tool_call_approved';
51
+ readonly callId: ToolCallId;
52
+ readonly decidedBy: 'policy' | 'resolver' | 'hook';
53
+ readonly mode: 'allow' | 'allow_session' | 'allow_always';
54
+ }
55
+ export interface ToolCallDeniedEvent extends EventBase {
56
+ readonly type: 'tool_call_denied';
57
+ readonly callId: ToolCallId;
58
+ readonly decidedBy: 'policy' | 'resolver' | 'hook';
59
+ readonly reason: string;
60
+ }
61
+ export interface ToolResultEvent extends EventBase {
62
+ readonly type: 'tool_result';
63
+ readonly callId: ToolCallId;
64
+ readonly ok: boolean;
65
+ readonly output?: unknown;
66
+ readonly error?: {
67
+ message: string;
68
+ kind: 'aborted' | 'threw' | 'denied' | 'timeout';
69
+ };
70
+ }
71
+ export interface SkillInvokedEvent extends EventBase {
72
+ readonly type: 'skill_invoked';
73
+ readonly skillId: SkillId;
74
+ readonly name: string;
75
+ readonly reason: 'trigger_match' | 'classifier' | 'manual' | 'load_skill_tool';
76
+ }
77
+ export interface SkillCreatedEvent extends EventBase {
78
+ readonly type: 'skill_created';
79
+ readonly skillId: SkillId;
80
+ readonly name: string;
81
+ readonly path: string;
82
+ readonly scope: 'user' | 'project';
83
+ readonly originatingPrompt: string;
84
+ }
85
+ export interface PluginRegisteredEvent extends EventBase {
86
+ readonly type: 'plugin_registered';
87
+ readonly pluginId: PluginId;
88
+ readonly name: string;
89
+ readonly version: string;
90
+ readonly kind: ReadonlyArray<'tools' | 'provider' | 'mode' | 'compactor' | 'cache-strategy' | 'view-renderer' | 'tunnel-provider' | 'mcp' | 'cli' | 'channel' | 'hooks' | 'agent' | 'command' | 'transcriber'>;
91
+ }
92
+ export interface PluginUnregisteredEvent extends EventBase {
93
+ readonly type: 'plugin_unregistered';
94
+ readonly pluginId: PluginId;
95
+ readonly name: string;
96
+ readonly reason: 'reload' | 'shutdown' | 'disabled';
97
+ }
98
+ export interface ModeIterationEvent extends EventBase {
99
+ readonly type: 'mode_iteration';
100
+ readonly strategy: string;
101
+ readonly iteration: number;
102
+ readonly routing?: 'resolved' | 'unresolved' | 'synthesized';
103
+ }
104
+ export interface CompactionEvent extends EventBase {
105
+ readonly type: 'compaction';
106
+ readonly compactor: string;
107
+ /**
108
+ * Inclusive `[fromSeq, toSeq]` range of event `seq` values this summary
109
+ * replaces — NOT array indices. Consumers (`projectMessagesFromLog`,
110
+ * `estimateContextTokens`) test `event.seq` against these bounds, so a
111
+ * compactor MUST emit the `seq` of the first/last replaced event. (Today
112
+ * `seq === arrayIndex` in the primary log, but that is not guaranteed for
113
+ * mirrors or partial views — emit seqs to stay correct regardless.)
114
+ */
115
+ readonly replacedRange: readonly [number, number];
116
+ readonly summary: string;
117
+ readonly tokensSaved: number;
118
+ }
119
+ /**
120
+ * Records a turn-boundary elision step (context-on-demand). Events at or below
121
+ * `elidedThrough` (and not covered by a compaction) are projected as compact
122
+ * stubs the model can expand with the `recall` tool. The high-water mark only
123
+ * advances on whole-turn boundaries, so the elided prefix stays byte-stable
124
+ * across the inner iterations of a turn — which is what lets prompt caching
125
+ * keep hitting.
126
+ */
127
+ export interface ElisionEvent extends EventBase {
128
+ readonly type: 'elision';
129
+ /** Inclusive seq high-water mark: events with `seq <= elidedThrough` are stubbed. */
130
+ readonly elidedThrough: number;
131
+ /** Turn-aligned [from,to] seq ranges newly stubbed by this step (informational). */
132
+ readonly stubbedRanges: ReadonlyArray<readonly [number, number]>;
133
+ /**
134
+ * Whether old user/assistant text turns (not just bulky tool results) are
135
+ * collapsed to stubs. Carried on the event so `projectMessagesFromLog` stays
136
+ * a pure function of the log (no need to thread config through projection).
137
+ * Note: even when true, conversational elision auto-disables for the session
138
+ * once seq-based `recall` calls reach `conversationalRecallThreshold`.
139
+ */
140
+ readonly elideConversational: boolean;
141
+ /**
142
+ * Adaptive safety: after this many `recall({ seq })` calls (the form used to
143
+ * recall elided TEXT turns), conversational elision turns off for the rest of
144
+ * the session. Carried on the event so projection decides it from the log.
145
+ */
146
+ readonly conversationalRecallThreshold: number;
147
+ /** Cap on total bytes of recalled content pinned verbatim below the HWM. */
148
+ readonly maxRecallBytes: number;
149
+ /** Tool names whose results are never stubbed (kept verbatim regardless of age). */
150
+ readonly neverElideTools: ReadonlyArray<string>;
151
+ readonly tokensSaved: number;
152
+ }
153
+ export interface ProviderRequestEvent extends EventBase {
154
+ readonly type: 'provider_request';
155
+ readonly provider: string;
156
+ readonly model: string;
157
+ readonly inputTokens?: number;
158
+ }
159
+ export interface ProviderResponseEvent extends EventBase {
160
+ readonly type: 'provider_response';
161
+ readonly provider: string;
162
+ readonly model: string;
163
+ readonly inputTokens?: number;
164
+ readonly outputTokens?: number;
165
+ readonly cacheReadTokens?: number;
166
+ readonly cacheCreationTokens?: number;
167
+ }
168
+ export interface ErrorEvent extends EventBase {
169
+ readonly type: 'error';
170
+ readonly kind: 'retryable' | 'fatal' | 'tool_threw' | 'hook_failed' | 'provider_failed';
171
+ readonly message: string;
172
+ readonly sourceEventId?: EventId;
173
+ readonly attempt?: number;
174
+ }
175
+ export interface AbortEvent extends EventBase {
176
+ readonly type: 'abort';
177
+ readonly reason: string;
178
+ }
179
+ export interface PluginEvent extends EventBase {
180
+ readonly type: 'plugin_event';
181
+ readonly pluginId: PluginId;
182
+ readonly subtype: string;
183
+ readonly payload: unknown;
184
+ }
185
+ export type MoxxyEvent = UserPromptEvent | AssistantChunkEvent | AssistantMessageEvent | ToolCallRequestedEvent | ToolCallApprovedEvent | ToolCallDeniedEvent | ToolResultEvent | SkillInvokedEvent | SkillCreatedEvent | PluginRegisteredEvent | PluginUnregisteredEvent | ModeIterationEvent | CompactionEvent | ElisionEvent | ProviderRequestEvent | ProviderResponseEvent | ErrorEvent | AbortEvent | PluginEvent;
186
+ export type MoxxyEventType = MoxxyEvent['type'];
187
+ export type MoxxyEventOfType<T extends MoxxyEventType> = Extract<MoxxyEvent, {
188
+ type: T;
189
+ }>;
190
+ export type EmittedEvent = MoxxyEvent extends infer E ? E extends MoxxyEvent ? Omit<E, 'id' | 'seq' | 'ts'> & {
191
+ ts?: number;
192
+ } : never : never;
193
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE1F,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAExF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC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IAAI,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1F,MAAM,MAAM,YAAY,GAAG,UAAU,SAAS,MAAM,CAAC,GACjD,CAAC,SAAS,UAAU,GAClB,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,KAAK,GACP,KAAK,CAAC"}
package/dist/events.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import type { MoxxyEvent, ToolCallRequestedEvent, ToolResultEvent } from './events.js';
2
+ import type { EventLogReader } from './log.js';
3
+ import type { PendingToolCall } from './permission.js';
4
+ import type { ProviderRequest } from './provider.js';
5
+ import type { SessionId, TurnId } from './ids.js';
6
+ export interface AppContext {
7
+ readonly sessionId: SessionId;
8
+ readonly cwd: string;
9
+ readonly log: EventLogReader;
10
+ readonly env: Readonly<Record<string, string | undefined>>;
11
+ }
12
+ export interface TurnContext extends AppContext {
13
+ readonly turnId: TurnId;
14
+ readonly iteration: number;
15
+ }
16
+ export interface ToolCallContext extends TurnContext {
17
+ readonly call: PendingToolCall;
18
+ }
19
+ export interface ToolResultContext extends TurnContext {
20
+ readonly result: ToolResultEvent;
21
+ }
22
+ export type ToolCallVerdict = {
23
+ readonly action: 'allow';
24
+ } | {
25
+ readonly action: 'deny';
26
+ readonly reason: string;
27
+ } | {
28
+ readonly action: 'rewrite';
29
+ readonly input: unknown;
30
+ };
31
+ export interface LifecycleHooks {
32
+ onInit?(ctx: AppContext): void | Promise<void>;
33
+ onTurnStart?(ctx: TurnContext): void | Promise<void>;
34
+ onBeforeProviderCall?(req: ProviderRequest, ctx: TurnContext): ProviderRequest | void | Promise<ProviderRequest | void>;
35
+ onToolCall?(ctx: ToolCallContext): ToolCallVerdict | void | Promise<ToolCallVerdict | void>;
36
+ onToolResult?(ctx: ToolResultContext): ToolResultEvent | void | Promise<ToolResultEvent | void>;
37
+ onEvent?(event: MoxxyEvent, ctx: AppContext): void | Promise<void>;
38
+ onTurnEnd?(ctx: TurnContext): void | Promise<void>;
39
+ onShutdown?(ctx: AppContext): void | Promise<void>;
40
+ }
41
+ export interface HookDispatcher {
42
+ dispatchInit(ctx: AppContext): Promise<void>;
43
+ dispatchTurnStart(ctx: TurnContext): Promise<void>;
44
+ dispatchBeforeProviderCall(req: ProviderRequest, ctx: TurnContext): Promise<ProviderRequest>;
45
+ dispatchToolCall(ctx: ToolCallContext): Promise<ToolCallVerdict>;
46
+ dispatchToolResult(ctx: ToolResultContext): Promise<ToolResultEvent>;
47
+ dispatchEvent(event: MoxxyEvent, ctx: AppContext): Promise<void>;
48
+ dispatchTurnEnd(ctx: TurnContext): Promise<void>;
49
+ dispatchShutdown(ctx: AppContext): Promise<void>;
50
+ }
51
+ export type ToolCallRequest = ToolCallRequestedEvent;
52
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,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","sources":["../src/hooks.ts"],"names":[],"mappings":""}
package/dist/ids.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ declare const brand: unique symbol;
2
+ type Brand<T, B extends string> = T & {
3
+ readonly [brand]: B;
4
+ };
5
+ export type EventId = Brand<string, 'EventId'>;
6
+ export type TurnId = Brand<string, 'TurnId'>;
7
+ export type ToolCallId = Brand<string, 'ToolCallId'>;
8
+ export type SessionId = Brand<string, 'SessionId'>;
9
+ export type PluginId = Brand<string, 'PluginId'>;
10
+ export type SkillId = Brand<string, 'SkillId'>;
11
+ export declare const asEventId: (s: string) => EventId;
12
+ export declare const asTurnId: (s: string) => TurnId;
13
+ export declare const asToolCallId: (s: string) => ToolCallId;
14
+ export declare const asSessionId: (s: string) => SessionId;
15
+ export declare const asPluginId: (s: string) => PluginId;
16
+ export declare const asSkillId: (s: string) => SkillId;
17
+ export {};
18
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AACnC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/C,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACnD,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACjD,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,OAAuB,CAAC;AAC9D,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,KAAG,MAAqB,CAAC;AAC3D,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,UAA6B,CAAC;AACvE,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,SAA2B,CAAC;AACpE,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,KAAG,QAAyB,CAAC;AACjE,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,KAAG,OAAuB,CAAC"}
package/dist/ids.js ADDED
@@ -0,0 +1,7 @@
1
+ export const asEventId = (s) => s;
2
+ export const asTurnId = (s) => s;
3
+ export const asToolCallId = (s) => s;
4
+ export const asSessionId = (s) => s;
5
+ export const asPluginId = (s) => s;
6
+ export const asSkillId = (s) => s;
7
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAY,CAAC;AAC9D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAW,CAAC;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAc,EAAE,CAAC,CAAe,CAAC;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAa,EAAE,CAAC,CAAc,CAAC;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAY,EAAE,CAAC,CAAa,CAAC;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAY,CAAC"}
@@ -0,0 +1,45 @@
1
+ export type { EventId, TurnId, ToolCallId, SessionId, PluginId, SkillId, } from './ids.js';
2
+ export { asEventId, asTurnId, asToolCallId, asSessionId, asPluginId, asSkillId } from './ids.js';
3
+ export type { EventBase, EventSource, MoxxyEvent, MoxxyEventType, MoxxyEventOfType, EmittedEvent, UserPromptEvent, UserPromptAttachment, AssistantChunkEvent, AssistantMessageEvent, ToolCallRequestedEvent, ToolCallApprovedEvent, ToolCallDeniedEvent, ToolResultEvent, SkillInvokedEvent, SkillCreatedEvent, PluginRegisteredEvent, PluginUnregisteredEvent, ModeIterationEvent, CompactionEvent, ProviderRequestEvent, ProviderResponseEvent, ErrorEvent, AbortEvent, PluginEvent, } from './events.js';
4
+ export type { EventLogReader } from './log.js';
5
+ export type { RunTurnOptions, SessionLogReader, SessionLike, SessionInfo, ProviderInfo, ToolInfo, SkillInfo, CommandInfo, } from './session-like.js';
6
+ export type { ClientSession, ProvidersClientView, ModesClientView, ToolsClientView, CommandsClientView, SkillsClientView, AgentsClientView, TranscribersClientView, RequirementsClientView, PermissionsClientView, } from './client-session.js';
7
+ export type { PermissionMode, PermissionDecision, PermissionRule, PendingToolCall, PermissionContext, PermissionResolver, } from './permission.js';
8
+ export type { ToolContext, ToolDef, ToolCompactPresentation, BrokeredFs, BrokeredStat, BrokeredFetch, BrokeredFetchInit, BrokeredFetchResponse, BrokeredExec, BrokeredExecOpts, BrokeredExecResult, } from './tool.js';
9
+ export type { FsCapability, NetCapability, CapabilitySpec, IsolationStrength, ToolIsolationSpec, IsolatedToolCall, Isolator, HandlerModuleRef, } from './isolation.js';
10
+ export { ISOLATION_RANK } from './isolation.js';
11
+ export type { SubagentSpec, SubagentResult, SubagentSpawner, } from './subagent.js';
12
+ export type { ContentBlock, ProviderMessage, ProviderRequest, ProviderEvent, CacheHint, TokenUsage, ModelDescriptor, LLMProvider, ProviderDef, ProviderKeyValidation, ProviderVault, ProviderAuthContext, ProviderOAuthResult, ProviderOAuthStatus, ProviderAuthDescriptor, } from './provider.js';
13
+ export type { CacheStrategyDef, CacheStrategyContext } from './cache-strategy.js';
14
+ export type { ViewNode, ViewAction, ViewDoc, ViewParseError, ViewParseResult, AttrType, AttrSpec, ViewTagSpec, ViewRendererDef, } from './view-renderer.js';
15
+ export { VIEW_PRIMITIVES, VIEW_COMPONENTS, DEFAULT_VIEW_TAGS } from './view-renderer.js';
16
+ export type { TunnelProviderDef, TunnelHandle, TunnelOpenOptions } from './tunnel.js';
17
+ export { isRetryableError, toFriendlyError, zodToJsonSchema, type StopReason } from './provider-utils.js';
18
+ export { MoxxyError, classifyHttpStatus, classifyNetworkError, type MoxxyErrorCode, type MoxxyErrorInit, } from './errors.js';
19
+ export { collectProviderStream, projectMessagesFromLog, projectMessages, buildSystemPromptWithSkills, type CollectedToolUse, type StreamResult, type ProjectMessagesOptions, type ProjectedMessages, } from './mode-helpers.js';
20
+ export { dispatchToolCall } from './tool-dispatch.js';
21
+ export type { TokenBudget, CompactContext, CompactorDef } from './compactor.js';
22
+ export { estimateContextTokens, runCompactionIfNeeded } from './compactor-helpers.js';
23
+ export { runElisionIfNeeded, resolveElisionSettings, type ResolvedElisionSettings, } from './elision-helpers.js';
24
+ export { computeElisionState, toolResultStub, conversationalStub, toolResultBytes, toolResultStubbed, conversationalStubbed, TINY_TURN_CHARS, type ElisionState, } from './elision-state.js';
25
+ export { applyLazyTools, buildToolIndex, loadedToolNames, ALWAYS_ON_TOOLS, type GatedTools, } from './tool-gating.js';
26
+ export { summarizeSessionTokens, summarizeSessionTokensFromEvents, summarizeTokensByModel, addModelTotals, usageEventFields, type SessionTokenSummary, type ModelUsageTotals, } from './token-accounting.js';
27
+ export type { Skill, SkillDef, SkillFrontmatter, SkillScope, SkillSchedule } from './skill.js';
28
+ export type { AgentDef } from './agent.js';
29
+ export type { CommandDef, CommandContext, CommandOutput, CommandHandlerResult, } from './command.js';
30
+ export type { ToolRegistry, SkillRegistry, PluginHostHandle, ModeContext, ModeDef, ElisionSettings, ApprovalResolver, ApprovalRequest, ApprovalDecision, ApprovalOption, } from './mode.js';
31
+ export type { AppContext, TurnContext, ToolCallContext, ToolResultContext, ToolCallVerdict, ToolCallRequest, LifecycleHooks, HookDispatcher, } from './hooks.js';
32
+ export type { PluginKind, PluginSpec, Plugin, PluginManifest, ResolvedPluginManifest, } from './plugin.js';
33
+ export type { Channel, ChannelHandle, ChannelStartOptsBase, ChannelFactoryDeps, ChannelDef, ChannelAvailability, ChannelRegistry, ChannelSubcommand, ChannelSubcommandContext, ChannelCommandArgs, } from './channel.js';
34
+ export type { EmbeddingProvider } from './embedding.js';
35
+ export { CachedEmbeddingProvider } from './embedding-cache.js';
36
+ export type { RequirementKind, RequirementState, MoxxyRequirement, RequirementIssue, RequirementCheck, } from './requirements.js';
37
+ export type { Transcriber, TranscriberDef, TranscriptionResult, TranscriptionSegment, TranscribeOptions, } from './transcriber.js';
38
+ export interface PluginLoader {
39
+ load(manifest: import('./plugin.js').ResolvedPluginManifest): Promise<import('./plugin.js').Plugin>;
40
+ }
41
+ export { definePlugin, defineTool, defineProvider, defineMode, defineCompactor, defineCacheStrategy, defineViewRenderer, defineTunnelProvider, defineChannel, definePermission, defineSkill, defineTranscriber, defineCommand, defineAgent, } from './define.js';
42
+ export { skillFrontmatterSchema, pluginManifestSchema, moxxyPackageSchema, requirementSchema, type SkillFrontmatterInput, type PluginManifestInput, type MoxxyPackageInput, } from './schemas.js';
43
+ export { getInstallHint, type InstallHint, type InstallTarget, } from './install-hints.js';
44
+ export { z } from 'zod';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEjG,YAAY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EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,QAAQ,EAAE,OAAO,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,aAAa,EAAE,MAAM,CAAC,CAAC;CACrG;AAED,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ export { asEventId, asTurnId, asToolCallId, asSessionId, asPluginId, asSkillId } from './ids.js';
2
+ export { ISOLATION_RANK } from './isolation.js';
3
+ export { VIEW_PRIMITIVES, VIEW_COMPONENTS, DEFAULT_VIEW_TAGS } from './view-renderer.js';
4
+ export { isRetryableError, toFriendlyError, zodToJsonSchema } from './provider-utils.js';
5
+ export { MoxxyError, classifyHttpStatus, classifyNetworkError, } from './errors.js';
6
+ export { collectProviderStream, projectMessagesFromLog, projectMessages, buildSystemPromptWithSkills, } from './mode-helpers.js';
7
+ export { dispatchToolCall } from './tool-dispatch.js';
8
+ export { estimateContextTokens, runCompactionIfNeeded } from './compactor-helpers.js';
9
+ export { runElisionIfNeeded, resolveElisionSettings, } from './elision-helpers.js';
10
+ export { computeElisionState, toolResultStub, conversationalStub, toolResultBytes, toolResultStubbed, conversationalStubbed, TINY_TURN_CHARS, } from './elision-state.js';
11
+ export { applyLazyTools, buildToolIndex, loadedToolNames, ALWAYS_ON_TOOLS, } from './tool-gating.js';
12
+ export { summarizeSessionTokens, summarizeSessionTokensFromEvents, summarizeTokensByModel, addModelTotals, usageEventFields, } from './token-accounting.js';
13
+ export { CachedEmbeddingProvider } from './embedding-cache.js';
14
+ export { definePlugin, defineTool, defineProvider, defineMode, defineCompactor, defineCacheStrategy, defineViewRenderer, defineTunnelProvider, defineChannel, definePermission, defineSkill, defineTranscriber, defineCommand, defineAgent, } from './define.js';
15
+ export { skillFrontmatterSchema, pluginManifestSchema, moxxyPackageSchema, requirementSchema, } from './schemas.js';
16
+ export { getInstallHint, } from './install-hints.js';
17
+ export { z } from 'zod';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAyFjG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAsChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAmB,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,oBAAoB,GAGrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,2BAA2B,GAK5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,GAEhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,EACtB,cAAc,EACd,gBAAgB,GAGjB,MAAM,uBAAuB,CAAC;AA0D/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAsB/D,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAIlB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Generic "how does the user install <thing> on their OS" helper, used by
3
+ * plugins that depend on a native binary they can't bundle themselves.
4
+ * Voice input wants ffmpeg; a transcription plugin might want
5
+ * `sox`/`opus-tools`; a doc-rendering plugin might want `pandoc`. Each
6
+ * caller passes either a single package name (when it's the same across
7
+ * platforms — the common case for widely-packaged tools) or a per-
8
+ * platform map for tools whose package name differs.
9
+ *
10
+ * The helper is informational. We never auto-run a system installer
11
+ * here: package managers prompt for sudo/UAC, and that doesn't fit a
12
+ * TUI cleanly. Callers render the returned command in their UI and the
13
+ * user runs it themselves.
14
+ */
15
+ export interface InstallTarget {
16
+ /** Canonical package name. Used when `perPlatform` has no entry for the active OS. */
17
+ readonly name: string;
18
+ /** Override the package name on specific platforms (e.g. `winget` IDs). */
19
+ readonly perPlatform?: Partial<Record<NodeJS.Platform, string>>;
20
+ }
21
+ export interface InstallHint {
22
+ readonly command: string;
23
+ readonly manager: string;
24
+ }
25
+ export declare function getInstallHint(target: string | InstallTarget, platform?: NodeJS.Platform): InstallHint;
26
+ //# sourceMappingURL=install-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-hints.d.ts","sourceRoot":"","sources":["../src/install-hints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GAAG,aAAa,EAC9B,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,WAAW,CAab"}
@@ -0,0 +1,15 @@
1
+ export function getInstallHint(target, platform = process.platform) {
2
+ const spec = typeof target === 'string' ? { name: target } : target;
3
+ const pkg = spec.perPlatform?.[platform] ?? spec.name;
4
+ if (platform === 'darwin') {
5
+ return { command: `brew install ${pkg}`, manager: 'Homebrew' };
6
+ }
7
+ if (platform === 'win32') {
8
+ return { command: `winget install ${pkg}`, manager: 'winget' };
9
+ }
10
+ if (platform === 'linux') {
11
+ return { command: `sudo apt install ${pkg}`, manager: 'apt' };
12
+ }
13
+ return { command: `install ${pkg} via your platform's package manager`, manager: 'manual' };
14
+ }
15
+ //# sourceMappingURL=install-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-hints.js","sourceRoot":"","sources":["../src/install-hints.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,cAAc,CAC5B,MAA8B,EAC9B,WAA4B,OAAO,CAAC,QAAQ;IAE5C,MAAM,IAAI,GAAkB,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACnF,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;IACtD,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,OAAO,EAAE,kBAAkB,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACjE,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,OAAO,EAAE,oBAAoB,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,sCAAsC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Filesystem capability declaration. Each entry is a glob; the special
3
+ * `$cwd` prefix resolves to `ToolContext.cwd` at call time, so a tool
4
+ * can declare "I only touch my own cwd" without hard-coding a path.
5
+ * Patterns are matched against absolute, normalized paths.
6
+ */
7
+ export interface FsCapability {
8
+ readonly read?: ReadonlyArray<string>;
9
+ readonly write?: ReadonlyArray<string>;
10
+ }
11
+ export type NetCapability = {
12
+ readonly mode: 'none';
13
+ } | {
14
+ readonly mode: 'any';
15
+ } | {
16
+ readonly mode: 'allowlist';
17
+ readonly hosts: ReadonlyArray<string>;
18
+ };
19
+ /**
20
+ * Declarative capability surface a tool requires. Plugin authors set
21
+ * this on `defineTool({ ..., isolation: { capabilities: {...} } })`.
22
+ *
23
+ * Treated as advisory until the user enables `@moxxy/plugin-security`.
24
+ * Once enabled, the active Isolator enforces these bounds at call time.
25
+ */
26
+ export interface CapabilitySpec {
27
+ readonly fs?: FsCapability;
28
+ readonly net?: NetCapability;
29
+ readonly env?: ReadonlyArray<string>;
30
+ /** Wall-clock budget in milliseconds. Aborted via ctx.signal on overrun. */
31
+ readonly timeMs?: number;
32
+ /** Soft memory ceiling in MB. Honored only by isolators that support it. */
33
+ readonly memMb?: number;
34
+ /** Whether the tool may spawn child processes. Defaults to false. */
35
+ readonly subprocess?: boolean;
36
+ /**
37
+ * Optional command allowlist for `ctx.exec` / brokered subprocess
38
+ * calls. Each entry can be a basename (`'echo'`) or absolute path
39
+ * (`'/bin/echo'`); a request matches if either form is in the list.
40
+ * Empty/omitted = no restriction beyond `subprocess: true`.
41
+ */
42
+ readonly commands?: ReadonlyArray<string>;
43
+ }
44
+ export type IsolationStrength = 'none' | 'inproc' | 'worker' | 'subprocess' | 'vm' | 'wasm' | 'docker';
45
+ export interface ToolIsolationSpec {
46
+ /**
47
+ * Minimum isolator strength the tool author considers acceptable. If the
48
+ * user's configured isolator is weaker, the security plugin denies the
49
+ * call rather than silently running with insufficient isolation.
50
+ */
51
+ readonly required?: IsolationStrength;
52
+ readonly capabilities: CapabilitySpec;
53
+ /**
54
+ * Module + export reference to the handler. Required for tools that
55
+ * want to be runnable under out-of-process isolators (`worker`,
56
+ * `subprocess`, …). When omitted, the tool is only executable under
57
+ * `none` / `inproc`; stronger isolators will deny.
58
+ *
59
+ * Convention: derive `url` from `import.meta.url` at `defineTool(...)` time:
60
+ * ```
61
+ * handlerModule: {
62
+ * url: new URL('./read-handler.js', import.meta.url).href,
63
+ * export: 'readHandler',
64
+ * }
65
+ * ```
66
+ * — that keeps the pointer correct after the package is published.
67
+ */
68
+ readonly handlerModule?: HandlerModuleRef;
69
+ }
70
+ /**
71
+ * Pointer to a tool's handler as a *module + export*. When present on
72
+ * `ToolDef.handlerModule`, stronger isolators (worker, subprocess, wasm)
73
+ * re-import that module on their side of the boundary and call the
74
+ * named export — closures aren't serializable across thread/process
75
+ * boundaries, so this declarative form is the only way to actually
76
+ * re-execute a handler outside the main process.
77
+ *
78
+ * `url` should be an absolute `file://` URL or import-resolvable path.
79
+ * The conventional shape is `new URL('./handler-module.js', import.meta.url).href`
80
+ * at `defineTool(...)` time, so the reference resolves correctly regardless
81
+ * of where the published package ends up on the consumer's disk.
82
+ */
83
+ export interface HandlerModuleRef {
84
+ /** Module URL (typically `file://...`) the isolator can `import()`. */
85
+ readonly url: string;
86
+ /** Named export of the handler within that module. */
87
+ readonly export: string;
88
+ }
89
+ export interface IsolatedToolCall {
90
+ readonly toolName: string;
91
+ readonly input: unknown;
92
+ readonly callId: string;
93
+ readonly sessionId: string;
94
+ readonly turnId: string;
95
+ readonly cwd: string;
96
+ /**
97
+ * Set by the security plugin when the tool declared `handlerModule`.
98
+ * Isolators that re-execute the handler off-thread (worker/subprocess/…)
99
+ * read this; in-process isolators (`none`, `inproc`) ignore it because
100
+ * they invoke the bound closure directly.
101
+ */
102
+ readonly moduleRef?: HandlerModuleRef;
103
+ }
104
+ /**
105
+ * Pluggable runtime for executing tools under a capability spec.
106
+ *
107
+ * The isolator receives:
108
+ * - `call.input` — the validated tool input.
109
+ * - `handler` — an in-process closure bound to the real `ToolContext`.
110
+ * In-process isolators (`none`, `inproc`) invoke this directly.
111
+ * - `call.moduleRef` — optional reference to the handler's source
112
+ * module. Out-of-process isolators (`worker`, `subprocess`, `wasm`)
113
+ * `import()` this on their side of the boundary and call the named
114
+ * export, because closures don't cross thread/process boundaries.
115
+ * An out-of-process isolator that receives a call with no `moduleRef`
116
+ * should deny: it has no way to actually run the handler in isolation.
117
+ */
118
+ export interface Isolator {
119
+ readonly name: string;
120
+ readonly strength: IsolationStrength;
121
+ run(call: IsolatedToolCall, handler: (input: unknown) => Promise<unknown>, caps: CapabilitySpec, signal: AbortSignal): Promise<unknown>;
122
+ }
123
+ /** Numerical ordering of isolation strengths. Higher = stricter. */
124
+ export declare const ISOLATION_RANK: Readonly<Record<IsolationStrength, number>>;
125
+ //# sourceMappingURL=isolation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolation.d.ts","sourceRoot":"","sources":["../src/isolation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,M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AAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,GAAG,CACD,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC7C,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,oEAAoE;AACpE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAQrE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** Numerical ordering of isolation strengths. Higher = stricter. */
2
+ export const ISOLATION_RANK = Object.freeze({
3
+ none: 0,
4
+ inproc: 1,
5
+ worker: 2,
6
+ subprocess: 3,
7
+ vm: 4,
8
+ wasm: 5,
9
+ docker: 6,
10
+ });
11
+ //# sourceMappingURL=isolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolation.js","sourceRoot":"","sources":["../src/isolation.ts"],"names":[],"mappings":"AA0IA,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAgD,MAAM,CAAC,MAAM,CAAC;IACvF,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC;IACb,EAAE,EAAE,CAAC;IACL,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;CACV,CAAC,CAAC"}
package/dist/log.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { MoxxyEvent, MoxxyEventOfType, MoxxyEventType } from './events.js';
2
+ import type { TurnId } from './ids.js';
3
+ export interface EventLogReader {
4
+ readonly length: number;
5
+ at(seq: number): MoxxyEvent | undefined;
6
+ slice(from?: number, to?: number): ReadonlyArray<MoxxyEvent>;
7
+ ofType<T extends MoxxyEventType>(type: T): ReadonlyArray<MoxxyEventOfType<T>>;
8
+ byTurn(turnId: TurnId): ReadonlyArray<MoxxyEvent>;
9
+ toJSON(): ReadonlyArray<MoxxyEvent>;
10
+ }
11
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;CACrC"}
package/dist/log.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":""}