@sentro/sdk 0.1.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.
@@ -0,0 +1,19 @@
1
+ import { SentroRun } from "./run";
2
+ import type { SentroConfig, EventLevel, StartRunOptions } from "./types";
3
+ export declare class Sentro {
4
+ private transport;
5
+ private parsedDsn;
6
+ private capturePrompts;
7
+ private tags;
8
+ private context;
9
+ constructor(config: SentroConfig);
10
+ setTags(tags: Record<string, string>): void;
11
+ setContext(context: Record<string, unknown>): void;
12
+ captureException(error: Error): void;
13
+ captureMessage(message: string, level?: EventLevel): void;
14
+ startRun(options: StartRunOptions): SentroRun;
15
+ trace<T>(agent: string, options: Omit<StartRunOptions, "agent">, fn: (run: SentroRun) => Promise<T>): Promise<T>;
16
+ flush(): Promise<void>;
17
+ shutdown(): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EACV,YAAY,EAEZ,UAAU,EACV,eAAe,EAChB,MAAM,SAAS,CAAC;AAYjB,qBAAa,MAAM;IACjB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,OAAO,CAA+B;gBAElC,MAAM,EAAE,YAAY;IAYhC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI3C,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIlD,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAYpC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,UAAmB,GAAG,IAAI;IAWjE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS;IAQvC,KAAK,CAAC,CAAC,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EACvC,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,CAAC,CAAC;IAYP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
package/dist/client.js ADDED
@@ -0,0 +1,82 @@
1
+ import { Transport } from "./transport";
2
+ import { SentroRun } from "./run";
3
+ function parseDsn(dsn) {
4
+ const url = new URL(dsn);
5
+ const token = url.username;
6
+ // pathname is like /api/ingest/projectId
7
+ const pathParts = url.pathname.split("/").filter(Boolean);
8
+ const projectId = pathParts[pathParts.length - 1];
9
+ const host = `${url.protocol}//${url.host}`;
10
+ return { host, token, projectId };
11
+ }
12
+ export class Sentro {
13
+ transport;
14
+ parsedDsn;
15
+ capturePrompts;
16
+ tags = {};
17
+ context = {};
18
+ constructor(config) {
19
+ this.parsedDsn = parseDsn(config.dsn);
20
+ this.capturePrompts = config.capturePrompts ?? false;
21
+ this.transport = new Transport(this.parsedDsn, {
22
+ flushIntervalMs: config.flushIntervalMs,
23
+ maxBatchSize: config.maxBatchSize,
24
+ });
25
+ if (config.defaultTags) {
26
+ this.tags = { ...config.defaultTags };
27
+ }
28
+ }
29
+ setTags(tags) {
30
+ this.tags = { ...this.tags, ...tags };
31
+ }
32
+ setContext(context) {
33
+ this.context = { ...this.context, ...context };
34
+ }
35
+ captureException(error) {
36
+ this.transport.send({
37
+ type: "event",
38
+ timestamp: new Date().toISOString(),
39
+ level: "error",
40
+ message: error.message,
41
+ stackTrace: error.stack,
42
+ tags: { ...this.tags },
43
+ context: { ...this.context },
44
+ });
45
+ }
46
+ captureMessage(message, level = "info") {
47
+ this.transport.send({
48
+ type: "event",
49
+ timestamp: new Date().toISOString(),
50
+ level,
51
+ message,
52
+ tags: { ...this.tags },
53
+ context: { ...this.context },
54
+ });
55
+ }
56
+ startRun(options) {
57
+ return new SentroRun(this.transport, options, {
58
+ capturePrompts: this.capturePrompts,
59
+ tags: this.tags,
60
+ context: this.context,
61
+ });
62
+ }
63
+ async trace(agent, options, fn) {
64
+ const run = this.startRun({ agent, ...options });
65
+ try {
66
+ const result = await fn(run);
67
+ await run.end({ status: "success" });
68
+ return result;
69
+ }
70
+ catch (err) {
71
+ await run.error(err instanceof Error ? err : new Error(String(err)));
72
+ throw err;
73
+ }
74
+ }
75
+ async flush() {
76
+ await this.transport.flush();
77
+ }
78
+ async shutdown() {
79
+ await this.transport.shutdown();
80
+ }
81
+ }
82
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQlC,SAAS,QAAQ,CAAC,GAAW;IAC3B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC3B,yCAAyC;IACzC,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;IAC5C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,OAAO,MA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,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { Sentro } from "./client";
2
+ export { SentroRun } from "./run";
3
+ export { SentroStep } from "./step";
4
+ export { SentroToolCall } from "./tool-call";
5
+ export { SentroLlmCall } from "./llm-call";
6
+ export type { SentroConfig, EventLevel, StartRunOptions, EndRunOptions, ToolCallOptions, EndToolCallOptions, LlmCallOptions, EndLlmCallOptions, } from "./types";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { Sentro } from "./client";
2
+ export { SentroRun } from "./run";
3
+ export { SentroStep } from "./step";
4
+ export { SentroToolCall } from "./tool-call";
5
+ export { SentroLlmCall } from "./llm-call";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Transport } from "./transport";
2
+ import type { LlmCallOptions, EndLlmCallOptions } from "./types";
3
+ interface LlmCallInternalOptions {
4
+ capturePrompts: boolean;
5
+ }
6
+ export declare class SentroLlmCall {
7
+ private transport;
8
+ private runId;
9
+ private stepId;
10
+ private llmCallId;
11
+ private capturePrompts;
12
+ constructor(transport: Transport, runId: string, stepId: string, options: LlmCallOptions, internal: LlmCallInternalOptions);
13
+ end(options?: EndLlmCallOptions): Promise<void>;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=llm-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-call.d.ts","sourceRoot":"","sources":["../src/llm-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAU;gBAG9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,sBAAsB;IA0B5B,GAAG,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBtD"}
@@ -0,0 +1,45 @@
1
+ export class SentroLlmCall {
2
+ transport;
3
+ runId;
4
+ stepId;
5
+ llmCallId;
6
+ capturePrompts;
7
+ constructor(transport, runId, stepId, options, internal) {
8
+ this.transport = transport;
9
+ this.runId = runId;
10
+ this.stepId = stepId;
11
+ this.llmCallId = crypto.randomUUID();
12
+ this.capturePrompts = internal.capturePrompts;
13
+ const event = {
14
+ type: "llm_call.start",
15
+ timestamp: new Date().toISOString(),
16
+ runId: this.runId,
17
+ stepId: this.stepId,
18
+ llmCallId: this.llmCallId,
19
+ model: options.model,
20
+ provider: options.provider,
21
+ temperature: options.temperature,
22
+ };
23
+ if (this.capturePrompts && options.messages) {
24
+ event.messages = options.messages;
25
+ }
26
+ this.transport.send(event);
27
+ }
28
+ async end(options) {
29
+ const event = {
30
+ type: "llm_call.end",
31
+ timestamp: new Date().toISOString(),
32
+ runId: this.runId,
33
+ stepId: this.stepId,
34
+ llmCallId: this.llmCallId,
35
+ promptTokens: options?.promptTokens,
36
+ completionTokens: options?.completionTokens,
37
+ cost: options?.cost,
38
+ };
39
+ if (this.capturePrompts && options?.response !== undefined) {
40
+ event.response = options.response;
41
+ }
42
+ this.transport.send(event);
43
+ }
44
+ }
45
+ //# sourceMappingURL=llm-call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-call.js","sourceRoot":"","sources":["../src/llm-call.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,aAAa;IAChB,SAAS,CAAY;IACrB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,cAAc,CAAU;IAEhC,YACE,SAAoB,EACpB,KAAa,EACb,MAAc,EACd,OAAuB,EACvB,QAAgC;QAEhC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;QAE9C,MAAM,KAAK,GAA4B;YACrC,IAAI,EAAE,gBAAgB;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;QAEF,IAAI,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC5C,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAsC,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAA2B;QACnC,MAAM,KAAK,GAA4B;YACrC,IAAI,EAAE,cAAc;YACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,OAAO,EAAE,YAAY;YACnC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;YAC3C,IAAI,EAAE,OAAO,EAAE,IAAI;SACpB,CAAC;QAEF,IAAI,IAAI,CAAC,cAAc,IAAI,OAAO,EAAE,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3D,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAsC,CAAC,CAAC;IAC9D,CAAC;CACF"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { Transport } from "./transport";
2
+ import { SentroStep } from "./step";
3
+ import type { StartRunOptions, EndRunOptions } from "./types";
4
+ interface RunInternalOptions {
5
+ capturePrompts: boolean;
6
+ tags: Record<string, string>;
7
+ context: Record<string, unknown>;
8
+ }
9
+ export declare class SentroRun {
10
+ private transport;
11
+ private runId;
12
+ private seq;
13
+ private capturePrompts;
14
+ private tags;
15
+ private context;
16
+ constructor(transport: Transport, options: StartRunOptions, internal: RunInternalOptions);
17
+ step(content: string): SentroStep;
18
+ trace<T>(content: string, fn: (step: SentroStep) => Promise<T>): Promise<T>;
19
+ end(options: EndRunOptions): Promise<void>;
20
+ error(error: Error): Promise<void>;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9D,UAAU,kBAAkB;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,OAAO,CAA0B;gBAGvC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,kBAAkB;IAsB9B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAO3B,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAY3E,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1C,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAOzC"}
package/dist/run.js ADDED
@@ -0,0 +1,64 @@
1
+ import { SentroStep } from "./step";
2
+ export class SentroRun {
3
+ transport;
4
+ runId;
5
+ seq = 0;
6
+ capturePrompts;
7
+ tags;
8
+ context;
9
+ constructor(transport, options, internal) {
10
+ this.transport = transport;
11
+ this.runId = crypto.randomUUID();
12
+ this.capturePrompts = internal.capturePrompts;
13
+ this.tags = internal.tags;
14
+ this.context = internal.context;
15
+ this.transport.send({
16
+ type: "run.start",
17
+ timestamp: new Date().toISOString(),
18
+ runId: this.runId,
19
+ agent: options.agent,
20
+ goal: options.goal,
21
+ model: options.model,
22
+ trigger: options.trigger,
23
+ metadata: options.metadata,
24
+ tags: { ...this.tags },
25
+ context: { ...this.context },
26
+ });
27
+ }
28
+ step(content) {
29
+ const seq = ++this.seq;
30
+ return new SentroStep(this.transport, this.runId, seq, content, {
31
+ capturePrompts: this.capturePrompts,
32
+ });
33
+ }
34
+ async trace(content, fn) {
35
+ const s = this.step(content);
36
+ try {
37
+ const result = await fn(s);
38
+ await s.end();
39
+ return result;
40
+ }
41
+ catch (err) {
42
+ await s.end();
43
+ throw err;
44
+ }
45
+ }
46
+ async end(options) {
47
+ this.transport.send({
48
+ type: "run.end",
49
+ timestamp: new Date().toISOString(),
50
+ runId: this.runId,
51
+ status: options.status,
52
+ errorType: options.errorType,
53
+ errorMessage: options.errorMessage,
54
+ });
55
+ }
56
+ async error(error) {
57
+ await this.end({
58
+ status: "failure",
59
+ errorType: error.name,
60
+ errorMessage: error.message,
61
+ });
62
+ }
63
+ }
64
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE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K,CAAI,OAAe,EAAE,EAAoC;QAClE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3B,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAsB;QAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAY;QACtB,MAAM,IAAI,CAAC,GAAG,CAAC;YACb,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,KAAK,CAAC,IAAI;YACrB,YAAY,EAAE,KAAK,CAAC,OAAO;SAC5B,CAAC,CAAC;IACL,CAAC;CACF"}
package/dist/step.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Transport } from "./transport";
2
+ import { SentroToolCall } from "./tool-call";
3
+ import { SentroLlmCall } from "./llm-call";
4
+ import type { ToolCallOptions, LlmCallOptions } from "./types";
5
+ interface StepInternalOptions {
6
+ capturePrompts: boolean;
7
+ }
8
+ export declare class SentroStep {
9
+ private transport;
10
+ private runId;
11
+ private seq;
12
+ private stepId;
13
+ private capturePrompts;
14
+ constructor(transport: Transport, runId: string, seq: number, content: string, internal: StepInternalOptions);
15
+ toolCall(toolName: string, options?: ToolCallOptions): SentroToolCall;
16
+ traceToolCall<T>(toolName: string, input: Record<string, unknown>, fn: (tc: SentroToolCall) => Promise<T>): Promise<T>;
17
+ llmCall(options: LlmCallOptions): SentroLlmCall;
18
+ end(): Promise<void>;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE/D,UAAU,mBAAmB;IAC3B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,cAAc,CAAU;gBAG9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,mBAAmB;IAkB/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc;IAI/D,aAAa,CAAC,CAAC,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,EAAE,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,CAAC,CAAC;IAYb,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAMzC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAS3B"}
package/dist/step.js ADDED
@@ -0,0 +1,54 @@
1
+ import { SentroToolCall } from "./tool-call";
2
+ import { SentroLlmCall } from "./llm-call";
3
+ export class SentroStep {
4
+ transport;
5
+ runId;
6
+ seq;
7
+ stepId;
8
+ capturePrompts;
9
+ constructor(transport, runId, seq, content, internal) {
10
+ this.transport = transport;
11
+ this.runId = runId;
12
+ this.seq = seq;
13
+ this.stepId = crypto.randomUUID();
14
+ this.capturePrompts = internal.capturePrompts;
15
+ this.transport.send({
16
+ type: "step.start",
17
+ timestamp: new Date().toISOString(),
18
+ runId: this.runId,
19
+ stepId: this.stepId,
20
+ seq: this.seq,
21
+ content,
22
+ });
23
+ }
24
+ toolCall(toolName, options) {
25
+ return new SentroToolCall(this.transport, this.runId, this.stepId, toolName, options);
26
+ }
27
+ async traceToolCall(toolName, input, fn) {
28
+ const tc = this.toolCall(toolName, { input });
29
+ try {
30
+ const result = await fn(tc);
31
+ await tc.end({ result });
32
+ return result;
33
+ }
34
+ catch (err) {
35
+ await tc.error(err instanceof Error ? err : new Error(String(err)));
36
+ throw err;
37
+ }
38
+ }
39
+ llmCall(options) {
40
+ return new SentroLlmCall(this.transport, this.runId, this.stepId, options, {
41
+ capturePrompts: this.capturePrompts,
42
+ });
43
+ }
44
+ async end() {
45
+ this.transport.send({
46
+ type: "step.end",
47
+ timestamp: new Date().toISOString(),
48
+ runId: this.runId,
49
+ stepId: this.stepId,
50
+ seq: this.seq,
51
+ });
52
+ }
53
+ }
54
+ //# sourceMappingURL=step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO3C,MAAM,OAAO,UAAU;IACb,SAAS,CAAY;IACrB,KAAK,CAAS;IACd,GAAG,CAAS;IACZ,MAAM,CAAS;IACf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CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAuB;QAC7B,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE;YACzE,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { Transport } from "./transport";
2
+ import type { ToolCallOptions, EndToolCallOptions } from "./types";
3
+ export declare class SentroToolCall {
4
+ private transport;
5
+ private runId;
6
+ private stepId;
7
+ private toolCallId;
8
+ private toolName;
9
+ constructor(transport: Transport, runId: string, stepId: string, toolName: string, options?: ToolCallOptions);
10
+ end(options?: EndToolCallOptions): Promise<void>;
11
+ error(error: Error): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=tool-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../src/tool-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEnE,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAGvB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,eAAe;IAmBrB,GAAG,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAchD,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC"}
@@ -0,0 +1,40 @@
1
+ export class SentroToolCall {
2
+ transport;
3
+ runId;
4
+ stepId;
5
+ toolCallId;
6
+ toolName;
7
+ constructor(transport, runId, stepId, toolName, options) {
8
+ this.transport = transport;
9
+ this.runId = runId;
10
+ this.stepId = stepId;
11
+ this.toolCallId = crypto.randomUUID();
12
+ this.toolName = toolName;
13
+ this.transport.send({
14
+ type: "tool_call.start",
15
+ timestamp: new Date().toISOString(),
16
+ runId: this.runId,
17
+ stepId: this.stepId,
18
+ toolCallId: this.toolCallId,
19
+ toolName: this.toolName,
20
+ input: options?.input,
21
+ });
22
+ }
23
+ async end(options) {
24
+ this.transport.send({
25
+ type: "tool_call.end",
26
+ timestamp: new Date().toISOString(),
27
+ runId: this.runId,
28
+ stepId: this.stepId,
29
+ toolCallId: this.toolCallId,
30
+ toolName: this.toolName,
31
+ status: options?.error ? "error" : "success",
32
+ result: options?.result,
33
+ error: options?.error,
34
+ });
35
+ }
36
+ async error(error) {
37
+ await this.end({ error: error.message });
38
+ }
39
+ }
40
+ //# sourceMappingURL=tool-call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call.js","sourceRoot":"","sources":["../src/tool-call.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACjB,SAAS,CAAY;IACrB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,QAAQ,CAAS;IAEzB,YACE,SAAoB,EACpB,KA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,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { ParsedDsn, IngestEvent } from "./types";
2
+ interface TransportOptions {
3
+ flushIntervalMs?: number;
4
+ maxBatchSize?: number;
5
+ }
6
+ export declare class Transport {
7
+ private dsn;
8
+ private buffer;
9
+ private flushIntervalMs;
10
+ private maxBatchSize;
11
+ private timer;
12
+ constructor(dsn: ParsedDsn, options?: TransportOptions);
13
+ send(event: IngestEvent): void;
14
+ flush(): Promise<void>;
15
+ shutdown(): Promise<void>;
16
+ private startTimer;
17
+ private stopTimer;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAErE,UAAU,gBAAgB;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,KAAK,CAA+C;gBAEhD,GAAG,EAAE,SAAS,EAAE,OAAO,GAAE,gBAAqB;IAO1D,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAOxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,SAAS;CAMlB"}
@@ -0,0 +1,55 @@
1
+ export class Transport {
2
+ dsn;
3
+ buffer = [];
4
+ flushIntervalMs;
5
+ maxBatchSize;
6
+ timer = null;
7
+ constructor(dsn, options = {}) {
8
+ this.dsn = dsn;
9
+ this.flushIntervalMs = options.flushIntervalMs ?? 1000;
10
+ this.maxBatchSize = options.maxBatchSize ?? 100;
11
+ this.startTimer();
12
+ }
13
+ send(event) {
14
+ this.buffer.push(event);
15
+ if (this.buffer.length >= this.maxBatchSize) {
16
+ this.flush();
17
+ }
18
+ }
19
+ async flush() {
20
+ if (this.buffer.length === 0)
21
+ return;
22
+ const batch = this.buffer.splice(0);
23
+ const payload = {
24
+ dsn: this.dsn.projectId,
25
+ batch,
26
+ };
27
+ try {
28
+ await fetch(`${this.dsn.host}/api/ingest`, {
29
+ method: "POST",
30
+ headers: {
31
+ "Content-Type": "application/json",
32
+ Authorization: `Bearer ${this.dsn.token}`,
33
+ },
34
+ body: JSON.stringify(payload),
35
+ });
36
+ }
37
+ catch {
38
+ // Drop events silently — no local queue for v1
39
+ }
40
+ }
41
+ async shutdown() {
42
+ this.stopTimer();
43
+ await this.flush();
44
+ }
45
+ startTimer() {
46
+ this.timer = setInterval(() => this.flush(), this.flushIntervalMs);
47
+ }
48
+ stopTimer() {
49
+ if (this.timer) {
50
+ clearInterval(this.timer);
51
+ this.timer = null;
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,SAAS;IACZ,GAAG,CAAY;IACf,MAAM,GAAkB,EAAE,CAAC;IAC3B,eAAe,CAAS;IACxB,YAAY,CAAS;IACrB,KAAK,GAA0C,IAAI,CAAC;IAE5D,YAAY,GAAc,EAAE,UAA4B,EAAE;QACxD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;QACvD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;QAChD,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,KAAkB;QACrB,IAAI,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H,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ export interface SentroConfig {
2
+ dsn: string;
3
+ capturePrompts?: boolean;
4
+ flushIntervalMs?: number;
5
+ maxBatchSize?: number;
6
+ defaultTags?: Record<string, string>;
7
+ }
8
+ export interface ParsedDsn {
9
+ host: string;
10
+ token: string;
11
+ projectId: string;
12
+ }
13
+ export type EventLevel = "error" | "warning" | "info" | "debug";
14
+ export type IngestEventType = "event" | "run.start" | "run.end" | "step.start" | "step.end" | "tool_call.start" | "tool_call.end" | "llm_call.start" | "llm_call.end";
15
+ export interface IngestEvent {
16
+ type: IngestEventType;
17
+ timestamp: string;
18
+ [key: string]: unknown;
19
+ }
20
+ export interface IngestPayload {
21
+ dsn: string;
22
+ batch: IngestEvent[];
23
+ }
24
+ export interface StartRunOptions {
25
+ agent: string;
26
+ goal?: string;
27
+ model?: string;
28
+ trigger?: string;
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ export interface EndRunOptions {
32
+ status: "success" | "failure" | "timeout";
33
+ errorType?: string;
34
+ errorMessage?: string;
35
+ }
36
+ export interface ToolCallOptions {
37
+ input?: Record<string, unknown>;
38
+ }
39
+ export interface EndToolCallOptions {
40
+ result?: unknown;
41
+ error?: string;
42
+ }
43
+ export interface LlmCallOptions {
44
+ model: string;
45
+ provider?: string;
46
+ messages?: Array<{
47
+ role: string;
48
+ content: string;
49
+ }>;
50
+ temperature?: number;
51
+ }
52
+ export interface EndLlmCallOptions {
53
+ response?: unknown;
54
+ promptTokens?: number;
55
+ completionTokens?: number;
56
+ cost?: number;
57
+ }
58
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,E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AM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@sentro/sdk",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": ["dist"],
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "vitest run",
10
+ "test:watch": "vitest",
11
+ "dev": "tsc --watch"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "^5.7.0",
15
+ "vitest": "^3.1.0"
16
+ }
17
+ }