@theoremjs/agents 0.3.5-next.941.g7a0e355 → 0.3.5-next.943.g77aa4ba

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.
@@ -65,6 +65,7 @@ export { systemPromptProblem } from './system-parts.js';
65
65
  export { activityLabelProblem } from './tools/activity-label.js';
66
66
  export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
67
67
  export type { ToolBackground, ToolBackgroundCall, ToolBackgroundHandle, ToolBackgroundService, ToolBackgroundSettled, ToolSteerReceipt, ToolSteerRefusal, } from './tools/background.js';
68
+ export { declaredInputSchema } from './tools/call-order.js';
68
69
  export type { StatedToolFailure } from './tools/failed.js';
69
70
  export { ToolFailed } from './tools/failed.js';
70
71
  export { type AnsweredGate, answerGatedCall, GATE_DECISIONS, type GateAnswerRequest, type GateDecision, gateExpired, type HeldGatedCall, resolveGateTtlMs, sessionPermissionsAfterApproval, type ToolGateAuth, } from './tools/gate-answer.js';
@@ -39,6 +39,7 @@ export { systemLinesProblem, systemReading } from './system-lines.js';
39
39
  export { systemPromptProblem } from './system-parts.js';
40
40
  export { activityLabelProblem } from './tools/activity-label.js';
41
41
  export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
42
+ export { declaredInputSchema } from './tools/call-order.js';
42
43
  export { ToolFailed } from './tools/failed.js';
43
44
  export { answerGatedCall, GATE_DECISIONS, gateExpired, resolveGateTtlMs, sessionPermissionsAfterApproval, } from './tools/gate-answer.js';
44
45
  export { createMemoryToolExecution } from './tools/memory-execution.js';
@@ -4,6 +4,14 @@ import type { StepCall } from '../stages.js';
4
4
  export declare function withModelField<TIn>(name: string, input: z.ZodType<TIn>, field: string, shape: () => z.ZodType): z.ZodType<TIn>;
5
5
  /** `input` with the model's `after` field. */
6
6
  export declare function withCallOrder<TIn>(name: string, input: z.ZodType<TIn>): z.ZodType<TIn>;
7
+ /**
8
+ * A registered tool's input schema as the tool declared it, without the `after` field the kernel
9
+ * added for the model. Registering the tool again from it adds the field once.
10
+ */
11
+ export declare function declaredInputSchema(tool: {
12
+ after?: boolean;
13
+ inputSchema: Record<string, unknown>;
14
+ }): Record<string, unknown>;
7
15
  /** The call's input without `after`, and the tool names `after` held. */
8
16
  export declare function splitCallOrder(tool: {
9
17
  after?: boolean;
@@ -29,6 +29,33 @@ export function withModelField(name, input, field, shape) {
29
29
  export function withCallOrder(name, input) {
30
30
  return withModelField(name, input, FIELD, orderField);
31
31
  }
32
+ /**
33
+ * A registered tool's input schema as the tool declared it, without the `after` field the kernel
34
+ * added for the model. Registering the tool again from it adds the field once.
35
+ */
36
+ export function declaredInputSchema(tool) {
37
+ return tool.after ? withoutField(tool.inputSchema, FIELD) : tool.inputSchema;
38
+ }
39
+ function withoutField(schema, field) {
40
+ const out = { ...schema };
41
+ const properties = schema.properties;
42
+ if (properties && typeof properties === 'object' && Object.hasOwn(properties, field)) {
43
+ const { [field]: _added, ...rest } = properties;
44
+ out.properties = rest;
45
+ if (Array.isArray(schema.required)) {
46
+ out.required = schema.required.filter((name) => name !== field);
47
+ }
48
+ }
49
+ for (const key of ['oneOf', 'anyOf']) {
50
+ const options = schema[key];
51
+ if (Array.isArray(options)) {
52
+ out[key] = options.map((option) => option && typeof option === 'object'
53
+ ? withoutField(option, field)
54
+ : option);
55
+ }
56
+ }
57
+ return out;
58
+ }
32
59
  /** The call's input without `after`, and the tool names `after` held. */
33
60
  export function splitCallOrder(tool, input) {
34
61
  if (!tool.after || typeof input !== 'object' || input === null)
@@ -86,6 +86,7 @@ export const toolOperationOutcomeSchema = z.strictObject({
86
86
  id: z.string().optional(),
87
87
  messages: z.array(turnHistoryMessageSchema),
88
88
  released: z.number().int().nonnegative().optional(),
89
+ promote: z.array(z.string().min(1)).optional(),
89
90
  }))
90
91
  .optional(),
91
92
  ended: z.literal(true).optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/agents",
3
- "version": "0.3.5-next.941.g7a0e355",
3
+ "version": "0.3.5-next.943.g77aa4ba",
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",