@standardagents/spec 0.39.0 → 0.39.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.d.ts CHANGED
@@ -1647,7 +1647,7 @@ interface ExecutionState {
1647
1647
  readonly stopped: boolean;
1648
1648
  /** Which side initiated the stop (if stopped) */
1649
1649
  readonly stoppedBy?: 'a' | 'b';
1650
- /** Message history loaded for current execution */
1650
+ /** Live chronological persisted history for the current execution */
1651
1651
  readonly messageHistory: Message[];
1652
1652
  /**
1653
1653
  * Force a specific side to play the next turn.
@@ -1873,6 +1873,12 @@ interface ThreadState {
1873
1873
  *
1874
1874
  * Creates a new message in the conversation history. This can be used
1875
1875
  * to add context, simulate user input, or insert assistant responses.
1876
+ * Runs `before_create_message` and `after_create_message`. If a
1877
+ * `before_create_message` hook throws, the returned promise rejects and
1878
+ * no message is persisted. During active execution, the persisted message
1879
+ * becomes immediately visible through `execution.messageHistory`.
1880
+ * `silent` controls client presentation only; silent messages remain
1881
+ * eligible for model context.
1876
1882
  *
1877
1883
  * @param message - The message to inject
1878
1884
  * @returns The created message
@@ -4418,10 +4424,14 @@ interface HookSignatures<State = ThreadState, Msg = HookMessage, ToolCall = Hook
4418
4424
  */
4419
4425
  after_system_message: (state: State, systemMessage: string) => string | Promise<string | null | undefined> | null | undefined;
4420
4426
  /**
4421
- * Called before messages are filtered and sent to the LLM.
4427
+ * Called exactly once per model-context assembly on a stable snapshot of
4428
+ * eligible persisted history.
4422
4429
  *
4423
4430
  * Receives raw message rows from storage before any transformation.
4424
4431
  * Use for filtering, sorting, or augmenting message history.
4432
+ * The result is the request context and does not replace
4433
+ * `state.execution.messageHistory`. Messages injected while this hook runs
4434
+ * become eligible for the following context assembly.
4425
4435
  *
4426
4436
  * @param state - Thread state
4427
4437
  * @param messages - Array of messages from storage
@@ -4438,10 +4448,12 @@ interface HookSignatures<State = ThreadState, Msg = HookMessage, ToolCall = Hook
4438
4448
  */
4439
4449
  filter_messages: (state: State, messages: Msg[]) => Promise<Msg[]>;
4440
4450
  /**
4441
- * Called after message history is loaded and before sending to LLM.
4451
+ * Called after filtered history is transformed into provider messages and
4452
+ * before dispatch.
4442
4453
  *
4443
4454
  * Receives messages already transformed into chat completion format.
4444
- * Use for final adjustments before LLM request.
4455
+ * Use for final request-local adjustments. Messages injected while this
4456
+ * hook runs become eligible for the following context assembly.
4445
4457
  *
4446
4458
  * @param state - Thread state
4447
4459
  * @param messages - Array of LLM-formatted messages
@@ -4463,6 +4475,10 @@ interface HookSignatures<State = ThreadState, Msg = HookMessage, ToolCall = Hook
4463
4475
  * Receives the full message object before insertion. Return modified
4464
4476
  * message to transform before storage.
4465
4477
  *
4478
+ * A hook that throws during `injectMessage()` rejects the injection and
4479
+ * no message is persisted. Other runtime insertions log the failure and
4480
+ * keep the last good message.
4481
+ *
4466
4482
  * @param state - Thread state
4467
4483
  * @param message - Message to be created
4468
4484
  * @returns Modified message