@vincemakes/kiso-core 0.43.0 → 0.44.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.
@@ -27,6 +27,13 @@ export interface ToolCallPayload {
27
27
  readonly callId: string;
28
28
  readonly name: string;
29
29
  readonly input: Readonly<Record<string, unknown>>;
30
+ /** 0.44.0 (#20): the invocation's arguments as the model streamed them —
31
+ * the same lexical evidence the tool receives as `ctx.rawInput`, on
32
+ * onPreTool and onPostTool alike, fresh or recovered; absent when no
33
+ * delta was streamed. Evidence for the host, never a control input: the
34
+ * approval chain never receives it, and validation, permission and
35
+ * execution read the parsed input. */
36
+ readonly rawInput?: string;
30
37
  }
31
38
  export interface HookHost {
32
39
  /** Assemble: rewrite or veto the incoming user message. null = drop. */
@@ -357,7 +357,7 @@ export async function* loop(config) {
357
357
  launches.push((async () => {
358
358
  try {
359
359
  decideChain = decideChain.then(async () => {
360
- const v = await decideCall(call, table, hooks, { signal: signal ?? NEVER_ABORT, ...(config.sessionId !== undefined ? { sessionId: config.sessionId } : {}) }, log, config.resolveApproval, config.approvalVerdict, signal, config.approvalPolicy, nextDecisionId, pushExec);
360
+ const v = await decideCall(call, table, hooks, { signal: signal ?? NEVER_ABORT, ...(config.sessionId !== undefined ? { sessionId: config.sessionId } : {}) }, log, config.resolveApproval, config.approvalVerdict, signal, config.approvalPolicy, nextDecisionId, pushExec, rawInput);
361
361
  askOrder.ahead = askGate;
362
362
  if (v.action === "ask") {
363
363
  askGate = new Promise((res) => {
@@ -1020,7 +1020,7 @@ function resultEvent(call, result, executionId) {
1020
1020
  * caller runs it (conservative ordering: the calls after an ask wait for
1021
1021
  * its resolution).
1022
1022
  */
1023
- async function decideCall(call, registry, hooks, ctx, log, resolveApproval, resolveApprovalVerdict, signal, approvalPolicy, nextDecisionId, push) {
1023
+ async function decideCall(call, registry, hooks, ctx, log, resolveApproval, resolveApprovalVerdict, signal, approvalPolicy, nextDecisionId, push, rawInput) {
1024
1024
  const payload = {
1025
1025
  callId: call.callId,
1026
1026
  name: call.name,
@@ -1157,7 +1157,9 @@ async function decideCall(call, registry, hooks, ctx, log, resolveApproval, reso
1157
1157
  // resolved by the human pause above — the static hook never speaks for
1158
1158
  // it, and a durable decision already spoke for the call).
1159
1159
  if (durable === undefined && chainVerdict === undefined && hooks.onPreTool) {
1160
- const decision = await raceAbort(hooks.onPreTool(payload, ctx), signal);
1160
+ // #20: the hook gets the lexical evidence; the chain above never did —
1161
+ // it decides on the parsed call, the object it has always received.
1162
+ const decision = await raceAbort(hooks.onPreTool(rawInput !== undefined ? { ...payload, rawInput } : payload, ctx), signal);
1161
1163
  if (signal?.aborted)
1162
1164
  throw ABORTED;
1163
1165
  if (decision.action === "defer") {
@@ -1269,7 +1271,7 @@ async function runLedgered(call, registry, hooks, ctx, signal, push) {
1269
1271
  };
1270
1272
  }
1271
1273
  if (hooks.onPostTool) {
1272
- result = await hooks.onPostTool({ callId: call.callId, name: call.name, input: call.input ?? {} }, result, ctx);
1274
+ result = await hooks.onPostTool({ callId: call.callId, name: call.name, input: call.input ?? {}, ...(ctx.rawInput !== undefined ? { rawInput: ctx.rawInput } : {}) }, result, ctx);
1273
1275
  }
1274
1276
  // ruling #12 correction one: a non-idempotent failure's side effects may have
1275
1277
  // partially applied — an honest note rides the RESULT (and the failed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-core",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "kiso core \u2014 protocol, event log, loop, hooks, modes, permissions, compaction, delivery truth. The 2,000-line kernel at the bottom of the kiso framework.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "openai"
34
34
  ],
35
35
  "devDependencies": {
36
- "@vincemakes/kiso-evals": "0.43.0",
36
+ "@vincemakes/kiso-evals": "0.44.0",
37
37
  "@types/node": "^26.1.2",
38
38
  "typescript": "^5.7.2",
39
39
  "vitest": "^3.0.0"