opsveritas-sdk 0.4.3 → 0.4.4
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.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +16 -3
- package/dist/index.mjs +15 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ declare function init(apiKey: string, options?: {
|
|
|
3
3
|
metadataOnly?: boolean;
|
|
4
4
|
}): void;
|
|
5
5
|
|
|
6
|
+
declare function reportAction(note: string, confirmed?: boolean): void;
|
|
6
7
|
declare function run<T>(agentName: string, fn: () => Promise<T>, opts?: {
|
|
7
8
|
userId?: string;
|
|
8
9
|
}): Promise<T>;
|
|
@@ -90,6 +91,7 @@ interface ExecutionPayload {
|
|
|
90
91
|
error_message?: string | null;
|
|
91
92
|
user_id?: string;
|
|
92
93
|
output_summary?: string;
|
|
94
|
+
action_confirmed?: boolean;
|
|
93
95
|
/** Set automatically by the SDK so the server can identify SDK vs raw-webhook ingestion. Not user-configurable. */
|
|
94
96
|
source?: 'sdk';
|
|
95
97
|
}
|
|
@@ -97,10 +99,11 @@ interface ExecutionPayload {
|
|
|
97
99
|
declare const OpsVeritas: {
|
|
98
100
|
init: typeof init;
|
|
99
101
|
run: typeof run;
|
|
102
|
+
reportAction: typeof reportAction;
|
|
100
103
|
trace: typeof trace;
|
|
101
104
|
wrap: typeof wrap;
|
|
102
105
|
langchain: typeof langchain;
|
|
103
106
|
wrapLangChain: typeof wrapLangChain;
|
|
104
107
|
};
|
|
105
108
|
|
|
106
|
-
export { type ExecutionPayload, type LangChainOptions, OpsVeritas, OpsVeritasKilledError, type TraceOptions, type WrapOptions, OpsVeritas as default, init, langchain, run, trace, wrap, wrapLangChain };
|
|
109
|
+
export { type ExecutionPayload, type LangChainOptions, OpsVeritas, OpsVeritasKilledError, type TraceOptions, type WrapOptions, OpsVeritas as default, init, langchain, reportAction, run, trace, wrap, wrapLangChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare function init(apiKey: string, options?: {
|
|
|
3
3
|
metadataOnly?: boolean;
|
|
4
4
|
}): void;
|
|
5
5
|
|
|
6
|
+
declare function reportAction(note: string, confirmed?: boolean): void;
|
|
6
7
|
declare function run<T>(agentName: string, fn: () => Promise<T>, opts?: {
|
|
7
8
|
userId?: string;
|
|
8
9
|
}): Promise<T>;
|
|
@@ -90,6 +91,7 @@ interface ExecutionPayload {
|
|
|
90
91
|
error_message?: string | null;
|
|
91
92
|
user_id?: string;
|
|
92
93
|
output_summary?: string;
|
|
94
|
+
action_confirmed?: boolean;
|
|
93
95
|
/** Set automatically by the SDK so the server can identify SDK vs raw-webhook ingestion. Not user-configurable. */
|
|
94
96
|
source?: 'sdk';
|
|
95
97
|
}
|
|
@@ -97,10 +99,11 @@ interface ExecutionPayload {
|
|
|
97
99
|
declare const OpsVeritas: {
|
|
98
100
|
init: typeof init;
|
|
99
101
|
run: typeof run;
|
|
102
|
+
reportAction: typeof reportAction;
|
|
100
103
|
trace: typeof trace;
|
|
101
104
|
wrap: typeof wrap;
|
|
102
105
|
langchain: typeof langchain;
|
|
103
106
|
wrapLangChain: typeof wrapLangChain;
|
|
104
107
|
};
|
|
105
108
|
|
|
106
|
-
export { type ExecutionPayload, type LangChainOptions, OpsVeritas, OpsVeritasKilledError, type TraceOptions, type WrapOptions, OpsVeritas as default, init, langchain, run, trace, wrap, wrapLangChain };
|
|
109
|
+
export { type ExecutionPayload, type LangChainOptions, OpsVeritas, OpsVeritasKilledError, type TraceOptions, type WrapOptions, OpsVeritas as default, init, langchain, reportAction, run, trace, wrap, wrapLangChain };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
default: () => index_default,
|
|
26
26
|
init: () => init,
|
|
27
27
|
langchain: () => langchain,
|
|
28
|
+
reportAction: () => reportAction,
|
|
28
29
|
run: () => run,
|
|
29
30
|
trace: () => trace,
|
|
30
31
|
wrap: () => wrap,
|
|
@@ -131,6 +132,13 @@ var storage = new import_async_hooks.AsyncLocalStorage();
|
|
|
131
132
|
function getActiveRun() {
|
|
132
133
|
return storage.getStore();
|
|
133
134
|
}
|
|
135
|
+
function reportAction(note, confirmed = true) {
|
|
136
|
+
const ctx = getActiveRun();
|
|
137
|
+
if (!ctx) return;
|
|
138
|
+
if (note) ctx.actionNotes.push(note);
|
|
139
|
+
if (confirmed === false) ctx.actionConfirmed = false;
|
|
140
|
+
else if (ctx.actionConfirmed === void 0) ctx.actionConfirmed = true;
|
|
141
|
+
}
|
|
134
142
|
async function run(agentName, fn, opts) {
|
|
135
143
|
const ctx = {
|
|
136
144
|
agentName,
|
|
@@ -138,7 +146,9 @@ async function run(agentName, fn, opts) {
|
|
|
138
146
|
startTime: Date.now(),
|
|
139
147
|
executedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
140
148
|
calls: [],
|
|
141
|
-
status: "success"
|
|
149
|
+
status: "success",
|
|
150
|
+
actionNotes: [],
|
|
151
|
+
actionConfirmed: void 0
|
|
142
152
|
};
|
|
143
153
|
return storage.run(ctx, async () => {
|
|
144
154
|
try {
|
|
@@ -154,7 +164,8 @@ async function run(agentName, fn, opts) {
|
|
|
154
164
|
const totalCost = ctx.calls.reduce((s, c) => s + (c.costUsd ?? 0), 0);
|
|
155
165
|
const models = [...new Set(ctx.calls.map((c) => c.model).filter((m) => !!m))];
|
|
156
166
|
const platform = ctx.calls[0]?.platform ?? "custom_webhook";
|
|
157
|
-
const
|
|
167
|
+
const callSummary = [...ctx.calls].reverse().find((c) => c.outputSummary)?.outputSummary;
|
|
168
|
+
const outputSummary = [callSummary, ...ctx.actionNotes].filter(Boolean).join("\n\n") || void 0;
|
|
158
169
|
const payload = {
|
|
159
170
|
platform,
|
|
160
171
|
agent_name: agentName,
|
|
@@ -169,6 +180,7 @@ async function run(agentName, fn, opts) {
|
|
|
169
180
|
if (models.length) payload.models = models;
|
|
170
181
|
if (ctx.userId) payload.user_id = ctx.userId;
|
|
171
182
|
if (outputSummary) payload.output_summary = outputSummary;
|
|
183
|
+
if (ctx.actionConfirmed !== void 0) payload.action_confirmed = ctx.actionConfirmed;
|
|
172
184
|
void sendExecution(payload);
|
|
173
185
|
}
|
|
174
186
|
});
|
|
@@ -776,7 +788,7 @@ function wrapLangChain(model, opts) {
|
|
|
776
788
|
}
|
|
777
789
|
|
|
778
790
|
// src/index.ts
|
|
779
|
-
var OpsVeritas = { init, run, trace, wrap, langchain, wrapLangChain };
|
|
791
|
+
var OpsVeritas = { init, run, reportAction, trace, wrap, langchain, wrapLangChain };
|
|
780
792
|
var index_default = OpsVeritas;
|
|
781
793
|
// Annotate the CommonJS export names for ESM import in node:
|
|
782
794
|
0 && (module.exports = {
|
|
@@ -784,6 +796,7 @@ var index_default = OpsVeritas;
|
|
|
784
796
|
OpsVeritasKilledError,
|
|
785
797
|
init,
|
|
786
798
|
langchain,
|
|
799
|
+
reportAction,
|
|
787
800
|
run,
|
|
788
801
|
trace,
|
|
789
802
|
wrap,
|
package/dist/index.mjs
CHANGED
|
@@ -97,6 +97,13 @@ var storage = new AsyncLocalStorage();
|
|
|
97
97
|
function getActiveRun() {
|
|
98
98
|
return storage.getStore();
|
|
99
99
|
}
|
|
100
|
+
function reportAction(note, confirmed = true) {
|
|
101
|
+
const ctx = getActiveRun();
|
|
102
|
+
if (!ctx) return;
|
|
103
|
+
if (note) ctx.actionNotes.push(note);
|
|
104
|
+
if (confirmed === false) ctx.actionConfirmed = false;
|
|
105
|
+
else if (ctx.actionConfirmed === void 0) ctx.actionConfirmed = true;
|
|
106
|
+
}
|
|
100
107
|
async function run(agentName, fn, opts) {
|
|
101
108
|
const ctx = {
|
|
102
109
|
agentName,
|
|
@@ -104,7 +111,9 @@ async function run(agentName, fn, opts) {
|
|
|
104
111
|
startTime: Date.now(),
|
|
105
112
|
executedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
106
113
|
calls: [],
|
|
107
|
-
status: "success"
|
|
114
|
+
status: "success",
|
|
115
|
+
actionNotes: [],
|
|
116
|
+
actionConfirmed: void 0
|
|
108
117
|
};
|
|
109
118
|
return storage.run(ctx, async () => {
|
|
110
119
|
try {
|
|
@@ -120,7 +129,8 @@ async function run(agentName, fn, opts) {
|
|
|
120
129
|
const totalCost = ctx.calls.reduce((s, c) => s + (c.costUsd ?? 0), 0);
|
|
121
130
|
const models = [...new Set(ctx.calls.map((c) => c.model).filter((m) => !!m))];
|
|
122
131
|
const platform = ctx.calls[0]?.platform ?? "custom_webhook";
|
|
123
|
-
const
|
|
132
|
+
const callSummary = [...ctx.calls].reverse().find((c) => c.outputSummary)?.outputSummary;
|
|
133
|
+
const outputSummary = [callSummary, ...ctx.actionNotes].filter(Boolean).join("\n\n") || void 0;
|
|
124
134
|
const payload = {
|
|
125
135
|
platform,
|
|
126
136
|
agent_name: agentName,
|
|
@@ -135,6 +145,7 @@ async function run(agentName, fn, opts) {
|
|
|
135
145
|
if (models.length) payload.models = models;
|
|
136
146
|
if (ctx.userId) payload.user_id = ctx.userId;
|
|
137
147
|
if (outputSummary) payload.output_summary = outputSummary;
|
|
148
|
+
if (ctx.actionConfirmed !== void 0) payload.action_confirmed = ctx.actionConfirmed;
|
|
138
149
|
void sendExecution(payload);
|
|
139
150
|
}
|
|
140
151
|
});
|
|
@@ -742,7 +753,7 @@ function wrapLangChain(model, opts) {
|
|
|
742
753
|
}
|
|
743
754
|
|
|
744
755
|
// src/index.ts
|
|
745
|
-
var OpsVeritas = { init, run, trace, wrap, langchain, wrapLangChain };
|
|
756
|
+
var OpsVeritas = { init, run, reportAction, trace, wrap, langchain, wrapLangChain };
|
|
746
757
|
var index_default = OpsVeritas;
|
|
747
758
|
export {
|
|
748
759
|
OpsVeritas,
|
|
@@ -750,6 +761,7 @@ export {
|
|
|
750
761
|
index_default as default,
|
|
751
762
|
init,
|
|
752
763
|
langchain,
|
|
764
|
+
reportAction,
|
|
753
765
|
run,
|
|
754
766
|
trace,
|
|
755
767
|
wrap,
|