@theoremjs/agents 0.3.4-next.590.g0246066 → 0.3.4-next.594.g145ceaf

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.
@@ -26,6 +26,11 @@ export type StageCallBag = {
26
26
  input?: unknown;
27
27
  /** `pre_tool` in a turn's step: every call the model made in the step, in the order it made them. */
28
28
  stepCalls?: readonly StepCall[];
29
+ /**
30
+ * `pre_tool`: the user approved this call where it stopped, at its permission or a
31
+ * confirmation. A sign-in is not an approval.
32
+ */
33
+ approved?: true;
29
34
  callNotStarted?: boolean;
30
35
  outputRaw?: unknown;
31
36
  outputModel?: ModelToolResult;
@@ -20,11 +20,13 @@ function defaultToolStageSupport(ctx) {
20
20
  export async function* runPreToolPipeline(args) {
21
21
  const { tool, ctx, base, stages } = args;
22
22
  let toolPreTool;
23
- // why: An approval skips the tool's own check it already passed — unless the user edited the arguments.
24
- const approvedAsIs = isGateResumeGranted(ctx.resume) &&
25
- ctx.resume?.edited === undefined &&
23
+ // why: Permission and sign-in gates come before `pre_tool`, so granting one answers nothing it asked.
24
+ const confirmed = isGateResumeGranted(ctx.resume) &&
26
25
  ctx.resume?.gateKind !== 'permission' &&
27
26
  ctx.resume?.gateKind !== 'auth';
27
+ // why: An approval skips the tool's own check it already passed — unless the user edited the arguments.
28
+ const approvedAsIs = confirmed && ctx.resume?.edited === undefined;
29
+ const approved = isGateResumeGranted(ctx.resume) && ctx.resume?.gateKind !== 'auth';
28
30
  if (tool.preTool && !approvedAsIs) {
29
31
  toolPreTool = (await tool.preTool(args.input, ctx)) ?? undefined;
30
32
  }
@@ -38,6 +40,8 @@ export async function* runPreToolPipeline(args) {
38
40
  input: args.input,
39
41
  toolPreTool,
40
42
  details: gateDetails(tool, args.input),
43
+ confirmed,
44
+ approved,
41
45
  });
42
46
  if (!pre.ok) {
43
47
  if (pre.kind === 'gated') {
@@ -91,7 +95,7 @@ export async function* runPreToolPipeline(args) {
91
95
  return { ok: true, input: reparsed ? reparsed.data : pre.input };
92
96
  }
93
97
  async function* runPreToolStages(args) {
94
- const { stages, toolName, callId, input, toolPreTool, details } = args;
98
+ const { stages, toolName, callId, input, toolPreTool, details, confirmed, approved } = args;
95
99
  const applied = yield* runStage({
96
100
  stage: 'pre_tool',
97
101
  step: stages.step,
@@ -105,6 +109,7 @@ async function* runPreToolStages(args) {
105
109
  callId,
106
110
  tool: toolName,
107
111
  input,
112
+ ...(approved ? { approved: true } : {}),
108
113
  ...(stages.stepCalls ? { stepCalls: stages.stepCalls } : {}),
109
114
  });
110
115
  if (applied.abort) {
@@ -118,7 +123,7 @@ async function* runPreToolStages(args) {
118
123
  denied: true,
119
124
  };
120
125
  }
121
- if (applied.confirm) {
126
+ if (applied.confirm && !confirmed) {
122
127
  const gate = {
123
128
  kind: 'confirmation',
124
129
  tool: toolName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/agents",
3
- "version": "0.3.4-next.590.g0246066",
3
+ "version": "0.3.4-next.594.g145ceaf",
4
4
  "description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
5
5
  "keywords": [
6
6
  "agent",