@rei-standard/amsg-shared 0.4.0-next.0 → 0.4.0-next.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/dist/index.cjs CHANGED
@@ -345,7 +345,8 @@ function buildSessionContext({
345
345
  contactName,
346
346
  avatarUrl,
347
347
  charId,
348
- metadata
348
+ metadata,
349
+ scratch
349
350
  }) {
350
351
  const llmOutputText = readLlmOutputText(llmResponse);
351
352
  const ctx = {
@@ -359,6 +360,7 @@ function buildSessionContext({
359
360
  contactName,
360
361
  avatarUrl: avatarUrl || void 0
361
362
  };
363
+ if (scratch !== void 0) ctx.scratch = scratch;
362
364
  return Object.freeze(ctx);
363
365
  }
364
366
  function readLlmOutputText(llmResponse) {
package/dist/index.d.cts CHANGED
@@ -316,6 +316,7 @@ export function stripReasoningTags(content: string): string;
316
316
  * @property {Record<string, unknown>} metadata
317
317
  * @property {string} contactName
318
318
  * @property {string} [avatarUrl]
319
+ * @property {Record<string, unknown>} [scratch] - Per-fire host scratch object. Producers that run several hooks within one fire (amsg-server's fire-time loop) pass the same mutable object to every hook of that fire, so hooks can hand context to each other without a module-level Map. The library never reads, writes, logs, or persists it, and never shares it across fires. Absent when the producer does not supply one (amsg-instant).
319
320
  */
320
321
  /**
321
322
  * Build the frozen SessionContext handed to an onLLMOutput hook.
@@ -335,9 +336,10 @@ export function stripReasoningTags(content: string): string;
335
336
  * @param {string} [args.avatarUrl]
336
337
  * @param {string} [args.charId]
337
338
  * @param {Record<string, unknown>} [args.metadata]
339
+ * @param {Record<string, unknown>} [args.scratch]
338
340
  * @returns {SessionContext}
339
341
  */
340
- export function buildSessionContext({ sessionId, messages, llmResponse, iteration, contactName, avatarUrl, charId, metadata, }: {
342
+ export function buildSessionContext({ sessionId, messages, llmResponse, iteration, contactName, avatarUrl, charId, metadata, scratch, }: {
341
343
  sessionId: string;
342
344
  messages: ChatMessage[];
343
345
  llmResponse: unknown;
@@ -346,6 +348,7 @@ export function buildSessionContext({ sessionId, messages, llmResponse, iteratio
346
348
  avatarUrl?: string;
347
349
  charId?: string;
348
350
  metadata?: Record<string, unknown>;
351
+ scratch?: Record<string, unknown>;
349
352
  }): SessionContext;
350
353
  /**
351
354
  * Extract the `choices[0].message` whole object — preserving `tool_calls`
@@ -687,6 +690,10 @@ export type SessionContext = {
687
690
  metadata: Record<string, unknown>;
688
691
  contactName: string;
689
692
  avatarUrl?: string;
693
+ /**
694
+ * - Per-fire host scratch object. Producers that run several hooks within one fire (amsg-server's fire-time loop) pass the same mutable object to every hook of that fire, so hooks can hand context to each other without a module-level Map. The library never reads, writes, logs, or persists it, and never shares it across fires. Absent when the producer does not supply one (amsg-instant).
695
+ */
696
+ scratch?: Record<string, unknown>;
690
697
  };
691
698
  /**
692
699
  * What the push carries. Fixed enum — packages must not add values.
package/dist/index.d.ts CHANGED
@@ -316,6 +316,7 @@ export function stripReasoningTags(content: string): string;
316
316
  * @property {Record<string, unknown>} metadata
317
317
  * @property {string} contactName
318
318
  * @property {string} [avatarUrl]
319
+ * @property {Record<string, unknown>} [scratch] - Per-fire host scratch object. Producers that run several hooks within one fire (amsg-server's fire-time loop) pass the same mutable object to every hook of that fire, so hooks can hand context to each other without a module-level Map. The library never reads, writes, logs, or persists it, and never shares it across fires. Absent when the producer does not supply one (amsg-instant).
319
320
  */
320
321
  /**
321
322
  * Build the frozen SessionContext handed to an onLLMOutput hook.
@@ -335,9 +336,10 @@ export function stripReasoningTags(content: string): string;
335
336
  * @param {string} [args.avatarUrl]
336
337
  * @param {string} [args.charId]
337
338
  * @param {Record<string, unknown>} [args.metadata]
339
+ * @param {Record<string, unknown>} [args.scratch]
338
340
  * @returns {SessionContext}
339
341
  */
340
- export function buildSessionContext({ sessionId, messages, llmResponse, iteration, contactName, avatarUrl, charId, metadata, }: {
342
+ export function buildSessionContext({ sessionId, messages, llmResponse, iteration, contactName, avatarUrl, charId, metadata, scratch, }: {
341
343
  sessionId: string;
342
344
  messages: ChatMessage[];
343
345
  llmResponse: unknown;
@@ -346,6 +348,7 @@ export function buildSessionContext({ sessionId, messages, llmResponse, iteratio
346
348
  avatarUrl?: string;
347
349
  charId?: string;
348
350
  metadata?: Record<string, unknown>;
351
+ scratch?: Record<string, unknown>;
349
352
  }): SessionContext;
350
353
  /**
351
354
  * Extract the `choices[0].message` whole object — preserving `tool_calls`
@@ -687,6 +690,10 @@ export type SessionContext = {
687
690
  metadata: Record<string, unknown>;
688
691
  contactName: string;
689
692
  avatarUrl?: string;
693
+ /**
694
+ * - Per-fire host scratch object. Producers that run several hooks within one fire (amsg-server's fire-time loop) pass the same mutable object to every hook of that fire, so hooks can hand context to each other without a module-level Map. The library never reads, writes, logs, or persists it, and never shares it across fires. Absent when the producer does not supply one (amsg-instant).
695
+ */
696
+ scratch?: Record<string, unknown>;
690
697
  };
691
698
  /**
692
699
  * What the push carries. Fixed enum — packages must not add values.
package/dist/index.mjs CHANGED
@@ -298,7 +298,8 @@ function buildSessionContext({
298
298
  contactName,
299
299
  avatarUrl,
300
300
  charId,
301
- metadata
301
+ metadata,
302
+ scratch
302
303
  }) {
303
304
  const llmOutputText = readLlmOutputText(llmResponse);
304
305
  const ctx = {
@@ -312,6 +313,7 @@ function buildSessionContext({
312
313
  contactName,
313
314
  avatarUrl: avatarUrl || void 0
314
315
  };
316
+ if (scratch !== void 0) ctx.scratch = scratch;
315
317
  return Object.freeze(ctx);
316
318
  }
317
319
  function readLlmOutputText(llmResponse) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rei-standard/amsg-shared",
3
- "version": "0.4.0-next.0",
3
+ "version": "0.4.0-next.1",
4
4
  "description": "ReiStandard Active Messaging shared types and push builders — the lowest layer (no deps on other amsg packages)",
5
5
  "repository": {
6
6
  "type": "git",