@cmodjs/core 5.1.0 → 5.1.1
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/package.json +1 -1
- package/records.d.ts +1 -1
- package/records.js +1 -1
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +12 -0
- package/src/records.ts +1 -1
- package/src/runtime/lifecycle.ts +13 -0
package/package.json
CHANGED
package/records.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export type Preferences = {
|
|
|
96
96
|
};
|
|
97
97
|
export declare function parsePreferences(value: unknown, path: string): Preferences;
|
|
98
98
|
export declare function parseConsent(value: unknown, path: string): Record<string, string[]>;
|
|
99
|
-
export declare const coreVersion = "5.1.
|
|
99
|
+
export declare const coreVersion = "5.1.1";
|
|
100
100
|
export declare const oldestCmodVersion = "5.1.0";
|
|
101
101
|
export declare function hotkeyCommand(mod: string, hotkey: string): string;
|
|
102
102
|
export declare function hotkeyBindings(mod: string, hotkeys: Hotkeys | undefined): Record<string, string>;
|
package/records.js
CHANGED
|
@@ -265,7 +265,7 @@ function readHotkeys(hotkeys) {
|
|
|
265
265
|
throw new Error(`package.json "cmod.hotkeys" is not a map of hotkeys to their title and optional default combo. ${fix}`);
|
|
266
266
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys) };
|
|
267
267
|
}
|
|
268
|
-
export const coreVersion = '5.1.
|
|
268
|
+
export const coreVersion = '5.1.1';
|
|
269
269
|
export const oldestCmodVersion = '5.1.0';
|
|
270
270
|
export function hotkeyCommand(mod, hotkey) {
|
|
271
271
|
return `${mod}--${hotkey}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/runtime/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAqB,WAAW,EAAE,MAAM,EAAc,aAAa,EAAwB,MAAM,aAAa,CAAA;AAGxI,OA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E,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IACxG,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1H,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACpF,CAAA;AAoDD,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBhE;AAmCD,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,OAAO,EACtF,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAClD,gBAAgB,GAAE,MAAM,gBAAgB,GAAG,SAA2B,EACtE,OAAO,GAAE,aAAkB,EAC3B,UAAU,UAAO,GAChB,SAAS,CAAC,KAAK,CAAC,CAqflB"}
|
package/runtime/lifecycle.js
CHANGED
|
@@ -27,6 +27,7 @@ import { createUi, partMethods } from './ui.js';
|
|
|
27
27
|
import { serveWidgets } from './widgets.js';
|
|
28
28
|
import { Progress } from '../ui/components.js';
|
|
29
29
|
import { Box, Text } from '../ui/elements.js';
|
|
30
|
+
const listenMethods = [conversationMethods.subscribe, conversationMethods.watchBefore];
|
|
30
31
|
const announcedKey = 'cmod:announced';
|
|
31
32
|
const cmodUpdatedKey = 'cmod:cmod-updated-for';
|
|
32
33
|
const installId = 'cmod:install';
|
|
@@ -128,6 +129,7 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
128
129
|
let recording;
|
|
129
130
|
let missedSessionStart;
|
|
130
131
|
let hasHeardSessionStart = false;
|
|
132
|
+
const heldListens = new Map();
|
|
131
133
|
let settleStart = () => undefined;
|
|
132
134
|
const startSettled = new Promise((resolve) => (settleStart = resolve));
|
|
133
135
|
const claude = () => {
|
|
@@ -290,6 +292,12 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
290
292
|
router = activeRouter;
|
|
291
293
|
phase = 'active';
|
|
292
294
|
stopWatchingRecord();
|
|
295
|
+
const held = [...heldListens.values()];
|
|
296
|
+
heldListens.clear();
|
|
297
|
+
for (const call of held) {
|
|
298
|
+
const failed = (error) => void toastFailure({ id: `listens:${String(call.caller)}`, message: `${String(call.caller)} hears nothing from this session`, error });
|
|
299
|
+
void activeRouter.dispatch('cmod.call', call, async () => ({ deny: `${definition.name} has no method ${call.method}.` })).then((answer) => ('deny' in answer ? failed(new Error(answer.deny)) : undefined), failed);
|
|
300
|
+
}
|
|
293
301
|
runtime.claude.ui.invalidate('ui.render');
|
|
294
302
|
if (definition.name === cmodPluginName)
|
|
295
303
|
runtime.claude.ui.invalidate('command.describe');
|
|
@@ -574,6 +582,10 @@ export function createLifecycle(definition, permissionRoutes = () => undefined,
|
|
|
574
582
|
return next(e);
|
|
575
583
|
}
|
|
576
584
|
if (isCallToThisMod && phase !== 'active') {
|
|
585
|
+
if (event === 'cmod.call' && listenMethods.includes(asked.method)) {
|
|
586
|
+
heldListens.set(`${asked.caller}\n${asked.method}\n${String(asked.input.session)}`, asked);
|
|
587
|
+
return { value: null };
|
|
588
|
+
}
|
|
577
589
|
return { deny: phase === 'failed' ? `${definition.name} is not set up. Its toast says why.` : `${definition.name} is installing. Try again when it's ready.` };
|
|
578
590
|
}
|
|
579
591
|
const call = e;
|
package/src/records.ts
CHANGED
|
@@ -306,7 +306,7 @@ function readHotkeys(hotkeys: unknown): Steps {
|
|
|
306
306
|
return { hotkeys: checkHotkeys('package.json "cmod"', hotkeys as Record<string, HotkeyInit>) }
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
export const coreVersion = '5.1.
|
|
309
|
+
export const coreVersion = '5.1.1'
|
|
310
310
|
|
|
311
311
|
export const oldestCmodVersion = '5.1.0'
|
|
312
312
|
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -49,6 +49,8 @@ export type Plugin = {
|
|
|
49
49
|
|
|
50
50
|
export type Phase = 'starting' | 'installing' | 'waiting' | 'failed' | 'ready' | 'active'
|
|
51
51
|
|
|
52
|
+
const listenMethods: readonly string[] = [conversationMethods.subscribe, conversationMethods.watchBefore]
|
|
53
|
+
|
|
52
54
|
export type Lifecycle<State extends object> = {
|
|
53
55
|
readonly phase: Phase
|
|
54
56
|
readonly mod: Mod<State> | undefined
|
|
@@ -208,6 +210,7 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
208
210
|
let recording: Promise<void> | undefined
|
|
209
211
|
let missedSessionStart: Frozen<Args<'classic.SessionStart'>> | undefined
|
|
210
212
|
let hasHeardSessionStart = false
|
|
213
|
+
const heldListens = new Map<string, Frozen<Args<'cmod.call'>> & { readonly caller?: string }>()
|
|
211
214
|
let settleStart: () => void = () => undefined
|
|
212
215
|
const startSettled = new Promise<void>((resolve) => (settleStart = resolve))
|
|
213
216
|
|
|
@@ -372,6 +375,12 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
372
375
|
router = activeRouter
|
|
373
376
|
phase = 'active'
|
|
374
377
|
stopWatchingRecord()
|
|
378
|
+
const held = [...heldListens.values()]
|
|
379
|
+
heldListens.clear()
|
|
380
|
+
for (const call of held) {
|
|
381
|
+
const failed = (error: unknown) => void toastFailure({ id: `listens:${String(call.caller)}`, message: `${String(call.caller)} hears nothing from this session`, error })
|
|
382
|
+
void activeRouter.dispatch('cmod.call', call, async () => ({ deny: `${definition.name} has no method ${call.method}.` })).then((answer) => ('deny' in answer ? failed(new Error(answer.deny)) : undefined), failed)
|
|
383
|
+
}
|
|
375
384
|
runtime.claude.ui.invalidate('ui.render')
|
|
376
385
|
if (definition.name === cmodPluginName) runtime.claude.ui.invalidate('command.describe')
|
|
377
386
|
void runSteps(active.mod).catch((error: unknown) => toastFailure({ id: 'cmod:steps', message: 'Its installer stopped', error, isCritical: true }))
|
|
@@ -633,6 +642,10 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
633
642
|
return next(e)
|
|
634
643
|
}
|
|
635
644
|
if (isCallToThisMod && phase !== 'active') {
|
|
645
|
+
if (event === 'cmod.call' && listenMethods.includes(asked.method)) {
|
|
646
|
+
heldListens.set(`${asked.caller}\n${asked.method}\n${String((asked.input as { readonly session?: unknown }).session)}`, asked)
|
|
647
|
+
return { value: null } as EventResult<N>
|
|
648
|
+
}
|
|
636
649
|
return { deny: phase === 'failed' ? `${definition.name} is not set up. Its toast says why.` : `${definition.name} is installing. Try again when it's ready.` } as EventResult<N>
|
|
637
650
|
}
|
|
638
651
|
const call = e as Frozen<Args<'cmod.call'>>
|