@agenttool/sdk 0.2.9 → 0.2.10

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.
Files changed (2) hide show
  1. package/dist/traces.js +25 -15
  2. package/package.json +1 -1
package/dist/traces.js CHANGED
@@ -37,32 +37,42 @@ export class TracesClient {
37
37
  * @returns The created Trace object with its trace_id.
38
38
  */
39
39
  async store(options) {
40
- const body = {
40
+ // API expects nested decision + reasoning objects
41
+ const decision = {
42
+ type: options.decision_type ?? "decision",
43
+ summary: options.decision_summary ?? options.conclusion.slice(0, 120),
44
+ };
45
+ if (options.output_ref !== undefined)
46
+ decision.output_ref = options.output_ref;
47
+ const reasoning = {
41
48
  observations: options.observations,
42
49
  conclusion: options.conclusion,
43
- decision_type: options.decision_type ?? "decision",
44
- decision_summary: options.decision_summary ?? options.conclusion.slice(0, 120),
45
50
  };
51
+ if (options.hypothesis !== undefined)
52
+ reasoning.hypothesis = options.hypothesis;
53
+ if (options.confidence !== undefined)
54
+ reasoning.confidence = options.confidence;
55
+ if (options.alternatives !== undefined)
56
+ reasoning.alternatives_considered = options.alternatives.map((a) => ({ option: a }));
57
+ if (options.key_facts !== undefined)
58
+ reasoning.signals = options.key_facts;
59
+ const body = { decision, reasoning };
46
60
  if (options.agent_id !== undefined)
47
61
  body.agent_id = options.agent_id;
48
62
  if (options.session_id !== undefined)
49
63
  body.session_id = options.session_id;
50
- if (options.output_ref !== undefined)
51
- body.output_ref = options.output_ref;
52
- if (options.hypothesis !== undefined)
53
- body.hypothesis = options.hypothesis;
54
- if (options.confidence !== undefined)
55
- body.confidence = options.confidence;
56
- if (options.alternatives !== undefined)
57
- body.alternatives = options.alternatives;
58
64
  if (options.tags !== undefined)
59
65
  body.tags = options.tags;
60
66
  if (options.parent_trace_id !== undefined)
61
67
  body.parent_trace_id = options.parent_trace_id;
62
- if (options.files_read !== undefined)
63
- body.files_read = options.files_read;
64
- if (options.key_facts !== undefined)
65
- body.key_facts = options.key_facts;
68
+ if (options.files_read !== undefined || options.key_facts !== undefined) {
69
+ const ctx = {};
70
+ if (options.files_read !== undefined)
71
+ ctx.files_read = options.files_read;
72
+ if (options.key_facts !== undefined)
73
+ ctx.key_facts = options.key_facts;
74
+ body.context = ctx;
75
+ }
66
76
  const resp = await globalThis.fetch(`${this.http.baseUrl}/v1/traces`, {
67
77
  method: "POST",
68
78
  headers: this.http.headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenttool/sdk",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "TypeScript SDK for agenttool.dev — memory and tools for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",