terse-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.
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +282 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/ApiRoutes.d.ts +274 -0
- package/dist/shared/ApiRoutes.d.ts.map +1 -0
- package/dist/shared/ApiRoutes.js +269 -0
- package/dist/shared/ApiRoutes.js.map +1 -0
- package/dist/shared/Configs.d.ts +425 -0
- package/dist/shared/Configs.d.ts.map +1 -0
- package/dist/shared/Configs.js +703 -0
- package/dist/shared/Configs.js.map +1 -0
- package/dist/shared/Entities.d.ts +8 -0
- package/dist/shared/Entities.d.ts.map +1 -0
- package/dist/shared/Entities.js +9 -0
- package/dist/shared/Entities.js.map +1 -0
- package/dist/shared/Integrations.d.ts +218 -0
- package/dist/shared/Integrations.d.ts.map +1 -0
- package/dist/shared/Integrations.js +134 -0
- package/dist/shared/Integrations.js.map +1 -0
- package/dist/shared/ModelEvents.d.ts +166 -0
- package/dist/shared/ModelEvents.d.ts.map +1 -0
- package/dist/shared/ModelEvents.js +14 -0
- package/dist/shared/ModelEvents.js.map +1 -0
- package/dist/shared/RunHistoryTypes.d.ts +94 -0
- package/dist/shared/RunHistoryTypes.d.ts.map +1 -0
- package/dist/shared/RunHistoryTypes.js +10 -0
- package/dist/shared/RunHistoryTypes.js.map +1 -0
- package/dist/shared/Survey.d.ts +10 -0
- package/dist/shared/Survey.d.ts.map +1 -0
- package/dist/shared/Survey.js +2 -0
- package/dist/shared/Survey.js.map +1 -0
- package/dist/shared/TicketSystem.d.ts +154 -0
- package/dist/shared/TicketSystem.d.ts.map +1 -0
- package/dist/shared/TicketSystem.js +21 -0
- package/dist/shared/TicketSystem.js.map +1 -0
- package/dist/shared/types.d.ts +744 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +16 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +18 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { InputEvent } from "./types.js";
|
|
2
|
+
import type { ConfigInstance } from "./shared/Configs.js";
|
|
3
|
+
import type { RunHistoryAction } from "./shared/RunHistoryTypes.js";
|
|
4
|
+
import { IntegrationType } from "./shared/Integrations.js";
|
|
5
|
+
export type { InputEvent, ToolboxEntry } from "./types.js";
|
|
6
|
+
export declare class MockInputEvent implements InputEvent {
|
|
7
|
+
readonly integrationType = IntegrationType.TERSE;
|
|
8
|
+
formatForAgentRunner(): string;
|
|
9
|
+
debugLog(): string;
|
|
10
|
+
}
|
|
11
|
+
export { ConfigType, ConfigInstance, GmailConfig, FigmaConfig, SlackConfig, SlackOutputConfig, GmailOutputConfig, GmailDraftOutputConfig, NotionConfig, LinearInputConfig, LinearOutputConfig, GitHubConfig, JiraConfig, ConfluenceConfig, PosthogConfig, DatadogConfig, TimeTriggerConfig, LaunchDarklyConfig, TerseConfig, WorkOSInputConfig, AttioOutputConfig } from "./shared/Configs.js";
|
|
12
|
+
export type { SdkAgentRunEventPayload, SdkAgentSkillPayload, SdkAgentRunOptionsPayload, SdkAgentRunRequestBody, SdkAgentRunResponseBody, SdkAgentStreamEvent, ToolOutputByName } from "./shared/types.js";
|
|
13
|
+
export { IntegrationType } from "./shared/Integrations.js";
|
|
14
|
+
export { RunHistoryAction, RunHistoryStatus, RunHistoryTrigger, RunHistoryDecision, RunHistoryRecord } from "./shared/RunHistoryTypes.js";
|
|
15
|
+
type Action = RunHistoryAction;
|
|
16
|
+
export type FilterConfiguration = {
|
|
17
|
+
criteria: string;
|
|
18
|
+
};
|
|
19
|
+
export type CreateJobParameters = {
|
|
20
|
+
name: string;
|
|
21
|
+
triggers: ConfigInstance[];
|
|
22
|
+
skills: ConfigInstance[];
|
|
23
|
+
filterConfiguration?: FilterConfiguration[];
|
|
24
|
+
onTrigger: (event: InputEvent, Agent: TerseAgent) => Promise<void>;
|
|
25
|
+
webhookURL: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const _jobRegistry: Map<string, CreateJobParameters>;
|
|
28
|
+
export declare class Terse {
|
|
29
|
+
constructor();
|
|
30
|
+
createJob(params: CreateJobParameters): void;
|
|
31
|
+
}
|
|
32
|
+
export declare class TerseAgent {
|
|
33
|
+
readonly skills: ConfigInstance[];
|
|
34
|
+
private readonly apiBaseUrl;
|
|
35
|
+
private readonly sessionId?;
|
|
36
|
+
constructor(skills?: ConfigInstance[], apiBaseUrl?: string, sessionId?: string);
|
|
37
|
+
run(prompt: string, event?: InputEvent): AsyncGenerator<TerseAgentResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Runs the agent to completion and discards streamed output.
|
|
40
|
+
* Useful when you only care that the run finished (or threw).
|
|
41
|
+
*/
|
|
42
|
+
runAndWait(prompt: string, event?: InputEvent): Promise<void>;
|
|
43
|
+
executeTool<TOutput = unknown>(toolName: string, params?: Record<string, unknown>): Promise<TOutput>;
|
|
44
|
+
}
|
|
45
|
+
export declare enum EventType {
|
|
46
|
+
TEXT = "text",
|
|
47
|
+
FINAL_OUTPUT = "final_output",
|
|
48
|
+
TOOL_CALL_PARAMS = "tool_call_params",
|
|
49
|
+
TOOL_CALL_STARTED = "tool_call_started",
|
|
50
|
+
TOOL_CALL_COMPLETED = "tool_call_completed",
|
|
51
|
+
ACTION = "action"
|
|
52
|
+
}
|
|
53
|
+
export interface TerseAgentResult {
|
|
54
|
+
type: EventType;
|
|
55
|
+
}
|
|
56
|
+
export declare class TextResult implements TerseAgentResult {
|
|
57
|
+
type: EventType.TEXT;
|
|
58
|
+
text: string;
|
|
59
|
+
constructor(text: string);
|
|
60
|
+
}
|
|
61
|
+
export declare class FinalOutputResult implements TerseAgentResult {
|
|
62
|
+
type: EventType.FINAL_OUTPUT;
|
|
63
|
+
finalOutput: string;
|
|
64
|
+
constructor(finalOutput: string);
|
|
65
|
+
}
|
|
66
|
+
export declare class ToolCallParamsResult implements TerseAgentResult {
|
|
67
|
+
type: EventType.TOOL_CALL_PARAMS;
|
|
68
|
+
toolCallParams: string;
|
|
69
|
+
constructor(toolCallParams: string);
|
|
70
|
+
}
|
|
71
|
+
export declare class ToolCallStartedResult implements TerseAgentResult {
|
|
72
|
+
type: EventType.TOOL_CALL_STARTED;
|
|
73
|
+
toolCallStarted: string;
|
|
74
|
+
constructor(toolCallStarted: string);
|
|
75
|
+
}
|
|
76
|
+
export declare class ToolCallCompletedResult implements TerseAgentResult {
|
|
77
|
+
type: EventType.TOOL_CALL_COMPLETED;
|
|
78
|
+
toolCallCompleted: string;
|
|
79
|
+
constructor(toolCallCompleted: string);
|
|
80
|
+
}
|
|
81
|
+
export declare class ActionResult implements TerseAgentResult {
|
|
82
|
+
type: EventType.ACTION;
|
|
83
|
+
action: Action;
|
|
84
|
+
constructor(action: Action);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG1D,qBAAa,cAAe,YAAW,UAAU;IAC7C,QAAQ,CAAC,eAAe,yBAAwB;IAEhD,oBAAoB,IAAI,MAAM;IAI9B,QAAQ,IAAI,MAAM;CAGrB;AAGD,OAAO,EACH,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,E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E,MAAM,CAAA;gBAEX,eAAe,EAAE,MAAM;CAItC;AAED,qBAAa,uBAAwB,YAAW,gBAAgB;IAC5D,IAAI,EAAE,SAAS,CAAC,mBAAmB,CAAA;IACnC,iBAAiB,EAAE,MAAM,CAAA;gBAEb,iBAAiB,EAAE,MAAM;CAIxC;AAED,qBAAa,YAAa,YAAW,gBAAgB;IACjD,IAAI,EAAE,SAAS,CAAC,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;gBAEF,MAAM,EAAE,MAAM;CAI7B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { CONFIG_DETAILS } from "./shared/Configs.js";
|
|
2
|
+
import { IntegrationType } from "./shared/Integrations.js";
|
|
3
|
+
import { ApiRoutes } from "./shared/ApiRoutes.js";
|
|
4
|
+
// Mock event for CLI's `terse run` command
|
|
5
|
+
export class MockInputEvent {
|
|
6
|
+
integrationType = IntegrationType.TERSE;
|
|
7
|
+
formatForAgentRunner() {
|
|
8
|
+
return "Manual trigger from terse run";
|
|
9
|
+
}
|
|
10
|
+
debugLog() {
|
|
11
|
+
return "[MockInputEvent] Manual trigger via CLI";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Re-export shared types for consumer convenience
|
|
15
|
+
export { ConfigType, GmailConfig, FigmaConfig, SlackConfig, SlackOutputConfig, GmailOutputConfig, GmailDraftOutputConfig, NotionConfig, LinearInputConfig, LinearOutputConfig, GitHubConfig, JiraConfig, ConfluenceConfig, PosthogConfig, DatadogConfig, TimeTriggerConfig, LaunchDarklyConfig, TerseConfig, WorkOSInputConfig, AttioOutputConfig } from "./shared/Configs.js";
|
|
16
|
+
export { IntegrationType } from "./shared/Integrations.js";
|
|
17
|
+
export { RunHistoryStatus } from "./shared/RunHistoryTypes.js";
|
|
18
|
+
/** Internal job registry — lives on globalThis so it survives across module instances (e.g. tsx loaders). */
|
|
19
|
+
const _global = globalThis;
|
|
20
|
+
_global.__terse_jobRegistry ??= new Map();
|
|
21
|
+
export const _jobRegistry = _global.__terse_jobRegistry;
|
|
22
|
+
export class Terse {
|
|
23
|
+
constructor() {
|
|
24
|
+
// fetch api_key from env
|
|
25
|
+
}
|
|
26
|
+
createJob(params) {
|
|
27
|
+
_jobRegistry.set(params.name, params);
|
|
28
|
+
// Deploy the job, run code in Modal Sandbox etc...
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class TerseAgent {
|
|
32
|
+
skills;
|
|
33
|
+
apiBaseUrl;
|
|
34
|
+
sessionId;
|
|
35
|
+
constructor(skills = [], apiBaseUrl = "http://localhost:3001", sessionId) {
|
|
36
|
+
this.skills = skills;
|
|
37
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
38
|
+
this.sessionId = sessionId;
|
|
39
|
+
}
|
|
40
|
+
async *run(prompt, event) {
|
|
41
|
+
const apiKey = process.env.TERSE_API_KEY;
|
|
42
|
+
if (!apiKey) {
|
|
43
|
+
throw new Error("TERSE_API_KEY environment variable is not set. Cannot run agent without authentication.");
|
|
44
|
+
}
|
|
45
|
+
const resolvedEvent = event ?? new MockInputEvent();
|
|
46
|
+
const skills = this.skills.map(skill => ({
|
|
47
|
+
configType: skill.configType,
|
|
48
|
+
config: serializeSkillConfig(skill)
|
|
49
|
+
}));
|
|
50
|
+
const requestBody = {
|
|
51
|
+
prompt,
|
|
52
|
+
event: {
|
|
53
|
+
integrationType: resolvedEvent.integrationType,
|
|
54
|
+
formattedContent: resolvedEvent.formatForAgentRunner(),
|
|
55
|
+
debugLog: resolvedEvent.debugLog()
|
|
56
|
+
},
|
|
57
|
+
skills
|
|
58
|
+
};
|
|
59
|
+
const headers = {
|
|
60
|
+
Authorization: `Bearer ${apiKey}`,
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
Accept: "text/event-stream"
|
|
63
|
+
};
|
|
64
|
+
if (this.sessionId)
|
|
65
|
+
headers["X-Terse-Session-Id"] = this.sessionId;
|
|
66
|
+
const runId = process.env.TERSE_RUN_ID;
|
|
67
|
+
if (runId)
|
|
68
|
+
headers["X-Terse-Run-Id"] = runId;
|
|
69
|
+
const res = await fetch(`${this.apiBaseUrl}${ApiRoutes.SDK.AGENT_RUN}`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers,
|
|
72
|
+
body: JSON.stringify(requestBody)
|
|
73
|
+
});
|
|
74
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
75
|
+
if (contentType.includes("text/event-stream")) {
|
|
76
|
+
if (!res.body) {
|
|
77
|
+
throw new Error("Agent run stream did not provide a response body.");
|
|
78
|
+
}
|
|
79
|
+
const failedToolCalls = [];
|
|
80
|
+
for await (const eventData of iterateSseDataLines(res.body)) {
|
|
81
|
+
const parsed = safeParseStreamEvent(eventData);
|
|
82
|
+
if (!parsed)
|
|
83
|
+
continue;
|
|
84
|
+
if (parsed.type === "done") {
|
|
85
|
+
if (failedToolCalls.length > 0) {
|
|
86
|
+
throw new Error(`Run completed with failed tool calls: ${failedToolCalls.join("; ")}`);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (parsed.type === "error") {
|
|
91
|
+
throw new Error(parsed.message);
|
|
92
|
+
}
|
|
93
|
+
if (parsed.type === "tool_call_completed") {
|
|
94
|
+
const parsedTool = parseToolCallCompleted(parsed.toolCallCompleted);
|
|
95
|
+
if (parsedTool && parsedTool.status && parsedTool.status !== "completed") {
|
|
96
|
+
failedToolCalls.push(`${parsedTool.tool}: ${parsedTool.status}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
yield mapStreamEventToResult(parsed);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const data = (await res.json());
|
|
104
|
+
if (!res.ok || !data.success) {
|
|
105
|
+
const details = data.details?.length ? ` (${data.details.join("; ")})` : "";
|
|
106
|
+
throw new Error(`${data.error ?? "Agent run failed"}${details}`);
|
|
107
|
+
}
|
|
108
|
+
yield new TextResult("Agent run request accepted.");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Runs the agent to completion and discards streamed output.
|
|
113
|
+
* Useful when you only care that the run finished (or threw).
|
|
114
|
+
*/
|
|
115
|
+
async runAndWait(prompt, event) {
|
|
116
|
+
for await (const _chunk of this.run(prompt, event)) {
|
|
117
|
+
// Intentionally drain the stream without returning output.
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async executeTool(toolName, params = {}) {
|
|
121
|
+
const apiKey = process.env.TERSE_API_KEY;
|
|
122
|
+
if (!apiKey) {
|
|
123
|
+
throw new Error("TERSE_API_KEY environment variable is not set. Cannot execute tools without authentication.");
|
|
124
|
+
}
|
|
125
|
+
const headers = {
|
|
126
|
+
Authorization: `Bearer ${apiKey}`,
|
|
127
|
+
"Content-Type": "application/json"
|
|
128
|
+
};
|
|
129
|
+
if (this.sessionId)
|
|
130
|
+
headers["X-Terse-Session-Id"] = this.sessionId;
|
|
131
|
+
const toolRunId = process.env.TERSE_RUN_ID;
|
|
132
|
+
if (toolRunId)
|
|
133
|
+
headers["X-Terse-Run-Id"] = toolRunId;
|
|
134
|
+
const res = await fetch(`${this.apiBaseUrl}${ApiRoutes.SDK.TOOL_EXECUTE}`, {
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers,
|
|
137
|
+
body: JSON.stringify({ toolName, params })
|
|
138
|
+
});
|
|
139
|
+
const data = (await res.json());
|
|
140
|
+
if (!data.success) {
|
|
141
|
+
throw new Error(data.error ?? "Tool execution failed");
|
|
142
|
+
}
|
|
143
|
+
return data.result;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function serializeSkillConfig(skill) {
|
|
147
|
+
const serialized = {};
|
|
148
|
+
for (const [key, value] of Object.entries(skill)) {
|
|
149
|
+
if (typeof value === "function" || value === undefined)
|
|
150
|
+
continue;
|
|
151
|
+
serialized[key] = value;
|
|
152
|
+
}
|
|
153
|
+
const details = CONFIG_DETAILS[skill.configType];
|
|
154
|
+
serialized.integrationType = details.integrationType;
|
|
155
|
+
serialized.configType = skill.configType;
|
|
156
|
+
return serialized;
|
|
157
|
+
}
|
|
158
|
+
export var EventType;
|
|
159
|
+
(function (EventType) {
|
|
160
|
+
EventType["TEXT"] = "text";
|
|
161
|
+
EventType["FINAL_OUTPUT"] = "final_output";
|
|
162
|
+
EventType["TOOL_CALL_PARAMS"] = "tool_call_params";
|
|
163
|
+
EventType["TOOL_CALL_STARTED"] = "tool_call_started";
|
|
164
|
+
EventType["TOOL_CALL_COMPLETED"] = "tool_call_completed";
|
|
165
|
+
EventType["ACTION"] = "action";
|
|
166
|
+
})(EventType || (EventType = {}));
|
|
167
|
+
export class TextResult {
|
|
168
|
+
type;
|
|
169
|
+
text;
|
|
170
|
+
constructor(text) {
|
|
171
|
+
this.type = EventType.TEXT;
|
|
172
|
+
this.text = text;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export class FinalOutputResult {
|
|
176
|
+
type;
|
|
177
|
+
finalOutput;
|
|
178
|
+
constructor(finalOutput) {
|
|
179
|
+
this.type = EventType.FINAL_OUTPUT;
|
|
180
|
+
this.finalOutput = finalOutput;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export class ToolCallParamsResult {
|
|
184
|
+
type;
|
|
185
|
+
toolCallParams;
|
|
186
|
+
constructor(toolCallParams) {
|
|
187
|
+
this.type = EventType.TOOL_CALL_PARAMS;
|
|
188
|
+
this.toolCallParams = toolCallParams;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export class ToolCallStartedResult {
|
|
192
|
+
type;
|
|
193
|
+
toolCallStarted;
|
|
194
|
+
constructor(toolCallStarted) {
|
|
195
|
+
this.type = EventType.TOOL_CALL_STARTED;
|
|
196
|
+
this.toolCallStarted = toolCallStarted;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export class ToolCallCompletedResult {
|
|
200
|
+
type;
|
|
201
|
+
toolCallCompleted;
|
|
202
|
+
constructor(toolCallCompleted) {
|
|
203
|
+
this.type = EventType.TOOL_CALL_COMPLETED;
|
|
204
|
+
this.toolCallCompleted = toolCallCompleted;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export class ActionResult {
|
|
208
|
+
type;
|
|
209
|
+
action;
|
|
210
|
+
constructor(action) {
|
|
211
|
+
this.type = EventType.ACTION;
|
|
212
|
+
this.action = action;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function* iterateSseDataLines(stream) {
|
|
216
|
+
const reader = stream.getReader();
|
|
217
|
+
const decoder = new TextDecoder();
|
|
218
|
+
let buffer = "";
|
|
219
|
+
try {
|
|
220
|
+
while (true) {
|
|
221
|
+
const { done, value } = await reader.read();
|
|
222
|
+
if (done)
|
|
223
|
+
break;
|
|
224
|
+
buffer += decoder.decode(value, { stream: true });
|
|
225
|
+
let separatorIndex = buffer.indexOf("\n\n");
|
|
226
|
+
while (separatorIndex !== -1) {
|
|
227
|
+
const rawEvent = buffer.slice(0, separatorIndex);
|
|
228
|
+
buffer = buffer.slice(separatorIndex + 2);
|
|
229
|
+
const dataLines = rawEvent
|
|
230
|
+
.split("\n")
|
|
231
|
+
.filter(line => line.startsWith("data:"))
|
|
232
|
+
.map(line => line.slice(5).trim())
|
|
233
|
+
.filter(Boolean);
|
|
234
|
+
if (dataLines.length > 0) {
|
|
235
|
+
yield dataLines.join("\n");
|
|
236
|
+
}
|
|
237
|
+
separatorIndex = buffer.indexOf("\n\n");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
reader.releaseLock();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function safeParseStreamEvent(raw) {
|
|
246
|
+
try {
|
|
247
|
+
return JSON.parse(raw);
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function mapStreamEventToResult(event) {
|
|
254
|
+
switch (event.type) {
|
|
255
|
+
case "text":
|
|
256
|
+
return new TextResult(event.text);
|
|
257
|
+
case "final_output":
|
|
258
|
+
return new FinalOutputResult(event.finalOutput);
|
|
259
|
+
case "tool_call_params":
|
|
260
|
+
return new ToolCallParamsResult(event.toolCallParams);
|
|
261
|
+
case "tool_call_started":
|
|
262
|
+
return new ToolCallStartedResult(event.toolCallStarted);
|
|
263
|
+
case "tool_call_completed":
|
|
264
|
+
return new ToolCallCompletedResult(event.toolCallCompleted);
|
|
265
|
+
case "action":
|
|
266
|
+
return new ActionResult(event.action);
|
|
267
|
+
case "done":
|
|
268
|
+
case "error":
|
|
269
|
+
return new TextResult("");
|
|
270
|
+
default:
|
|
271
|
+
return new TextResult("");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function parseToolCallCompleted(raw) {
|
|
275
|
+
try {
|
|
276
|
+
return JSON.parse(raw);
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAIpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAIjD,2CAA2C;AAC3C,MAAM,OAAO,cAAc;IACd,eAAe,GAAG,eAAe,CAAC,KAAK,CAAA;IAEhD,oBAAoB;QAChB,OAAO,+BAA+B,CAAA;IAC1C,CAAC;IAED,QAAQ;QACJ,OAAO,yCAAyC,CAAA;IACpD,CAAC;CACJ;AAED,kDAAkD;AAClD,OAAO,EACH,UAAU,EAEV,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,E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C;AAED,SAAS,sBAAsB,CAAC,KAA0B;IACtD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,MAAM;YACP,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrC,KAAK,cAAc;YACf,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QACnD,KAAK,kBAAkB;YACnB,OAAO,IAAI,oBAAoB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACzD,KAAK,mBAAmB;YACpB,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;QAC3D,KAAK,qBAAqB;YACtB,OAAO,IAAI,uBAAuB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAC/D,KAAK,QAAQ;YACT,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACzC,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACR,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B;YACI,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAA;IACjC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAW;IACvC,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuC,CAAA;IAChE,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAA;IACf,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API route path constants
|
|
3
|
+
*
|
|
4
|
+
* These constants standardize API route paths across frontend and backend,
|
|
5
|
+
* preventing magic strings and making refactoring easier.
|
|
6
|
+
*
|
|
7
|
+
* Dynamic routes use route objects with both Express patterns and URL builders
|
|
8
|
+
* to ensure frontend and backend stay in sync.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ApiRoutes: {
|
|
11
|
+
readonly AUTH: {
|
|
12
|
+
readonly ME: "/me";
|
|
13
|
+
readonly LOGIN: "/login";
|
|
14
|
+
readonly LOGIN_URL: "/login/url";
|
|
15
|
+
readonly LOGOUT: "/logout";
|
|
16
|
+
readonly LOGOUT_URL: "/logout/url";
|
|
17
|
+
readonly GITHUB_APP_CALLBACK: "/auth/github-app/callback";
|
|
18
|
+
readonly WORKOS_CALLBACK: "/auth/workos/callback";
|
|
19
|
+
};
|
|
20
|
+
readonly WORKOS: {
|
|
21
|
+
readonly WIDGET_TOKEN: "/auth/workos/widget-token";
|
|
22
|
+
};
|
|
23
|
+
readonly ORGANIZATIONS: {
|
|
24
|
+
readonly CREATE: "/organizations";
|
|
25
|
+
readonly GET_CURRENT: "/organizations/current";
|
|
26
|
+
readonly LIST: "/organizations";
|
|
27
|
+
readonly SWITCH: "/organizations/switch";
|
|
28
|
+
readonly UPDATE: "/organizations";
|
|
29
|
+
readonly LOGO_UPLOAD_URL: "/organizations/logo/upload-url";
|
|
30
|
+
readonly LOGO: {
|
|
31
|
+
readonly pattern: "/organizations/:organizationId/logo";
|
|
32
|
+
readonly build: (organizationId: string) => string;
|
|
33
|
+
readonly params: {
|
|
34
|
+
readonly organizationId: "string";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly STATS: "/stats";
|
|
39
|
+
readonly RUN_HISTORY: {
|
|
40
|
+
readonly ALL: "/run-history";
|
|
41
|
+
readonly ACTIONS: "/run-history/actions";
|
|
42
|
+
readonly BY_AGENT_ID: {
|
|
43
|
+
readonly pattern: "/run-history/:agentId";
|
|
44
|
+
readonly build: (agentId: string) => string;
|
|
45
|
+
readonly params: {
|
|
46
|
+
readonly agentId: "string";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly CHAT_BY_RUN_ID: {
|
|
50
|
+
readonly pattern: "/run-history/:runId/chat";
|
|
51
|
+
readonly build: (runId: string) => string;
|
|
52
|
+
readonly params: {
|
|
53
|
+
readonly runId: "string";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
readonly SESSION: {
|
|
58
|
+
readonly TOKEN: "/session/token";
|
|
59
|
+
};
|
|
60
|
+
readonly GITHUB: {
|
|
61
|
+
readonly INTEGRATIONS: "/github/integrations";
|
|
62
|
+
readonly INSTALLATION_URL: "/github/installation-url";
|
|
63
|
+
readonly GET_REPOSITORIES_FOR_INTEGRATION: "/github/get-repositories-for-integration";
|
|
64
|
+
readonly INSTALLATION_CALLBACK: "/github/installation-callback";
|
|
65
|
+
readonly INSTALLATION_DELETED: "/github/installation-deleted";
|
|
66
|
+
readonly UNIFIED_EVENT: "/github/unified-event";
|
|
67
|
+
};
|
|
68
|
+
readonly ATLASSIAN: {
|
|
69
|
+
readonly INTEGRATIONS: "/atlassian/integrations";
|
|
70
|
+
readonly OAUTH_CALLBACK: "/atlassian/oauth/callback";
|
|
71
|
+
};
|
|
72
|
+
readonly JIRA: {
|
|
73
|
+
readonly RESOURCES: "/jira/resources";
|
|
74
|
+
readonly GET_API_KEY: "/jira/get-api-key";
|
|
75
|
+
readonly SET_API_KEY: "/jira/set-api-key";
|
|
76
|
+
readonly VALIDATE_AND_FETCH_PROJECTS: "/jira/validate-and-fetch-projects";
|
|
77
|
+
readonly DELETE_CREDENTIALS: "/jira/delete-credentials";
|
|
78
|
+
};
|
|
79
|
+
readonly CONFLUENCE: {
|
|
80
|
+
readonly INTEGRATIONS: "/confluence/integrations";
|
|
81
|
+
readonly RESOURCES: "/confluence/resources";
|
|
82
|
+
};
|
|
83
|
+
readonly GMAIL: {
|
|
84
|
+
readonly INTEGRATIONS: "/gmail/integrations";
|
|
85
|
+
readonly CALLBACK: "/gmail/callback";
|
|
86
|
+
readonly DELETE_INTEGRATION: "/gmail/delete-integration";
|
|
87
|
+
};
|
|
88
|
+
readonly NOTION: {
|
|
89
|
+
readonly INTEGRATIONS: "/notion/integrations";
|
|
90
|
+
readonly OAUTH_CALLBACK: "/notion/oauth/callback";
|
|
91
|
+
readonly RESOURCES: "/notion/resources";
|
|
92
|
+
readonly DELETE_INTEGRATION: "/notion/delete-integration";
|
|
93
|
+
};
|
|
94
|
+
readonly FIGMA: {
|
|
95
|
+
readonly INTEGRATIONS: "/figma/integrations";
|
|
96
|
+
readonly OAUTH_CALLBACK: "/figma/oauth/callback";
|
|
97
|
+
};
|
|
98
|
+
readonly LINEAR: {
|
|
99
|
+
readonly OAUTH_CALLBACK: "/linear/oauth/callback";
|
|
100
|
+
readonly WEBHOOK: "/linear/webhook";
|
|
101
|
+
readonly INTEGRATIONS: "/linear/integrations";
|
|
102
|
+
readonly TEAMS: "/linear/teams";
|
|
103
|
+
};
|
|
104
|
+
readonly SLACK: {
|
|
105
|
+
readonly INTEGRATIONS: "/slack/integrations";
|
|
106
|
+
readonly GET_CURRENT_INTEGRATION: "/slack/get-current-integration";
|
|
107
|
+
readonly OAUTH_CALLBACK: "/slack/oauth-callback";
|
|
108
|
+
readonly CHANNELS: "/slack/channels";
|
|
109
|
+
readonly USERS: "/slack/users";
|
|
110
|
+
readonly EVENTS: "/slack/events";
|
|
111
|
+
};
|
|
112
|
+
readonly POSTHOG: {
|
|
113
|
+
readonly INTEGRATIONS: "/posthog/integrations";
|
|
114
|
+
readonly PROJECTS: "/posthog/projects";
|
|
115
|
+
};
|
|
116
|
+
readonly LAUNCHDARKLY: {
|
|
117
|
+
readonly INTEGRATIONS: "/launchdarkly/integrations";
|
|
118
|
+
readonly PROJECTS_BY_INTEGRATION_ID: {
|
|
119
|
+
readonly pattern: "/launchdarkly/integrations/:integrationId/projects";
|
|
120
|
+
readonly build: (integrationId: string) => string;
|
|
121
|
+
readonly params: {
|
|
122
|
+
readonly integrationId: "string";
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly ENVIRONMENTS_BY_INTEGRATION_AND_PROJECT: {
|
|
126
|
+
readonly pattern: "/launchdarkly/integrations/:integrationId/projects/:projectKey/environments";
|
|
127
|
+
readonly build: (integrationId: string, projectKey: string) => string;
|
|
128
|
+
readonly params: {
|
|
129
|
+
readonly integrationId: "string";
|
|
130
|
+
readonly projectKey: "string";
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
readonly DATADOG: {
|
|
135
|
+
readonly INTEGRATIONS: "/datadog/integrations";
|
|
136
|
+
readonly INDEXES: "/datadog/indexes";
|
|
137
|
+
};
|
|
138
|
+
readonly WORKOS_INTEGRATION: {
|
|
139
|
+
readonly INTEGRATIONS: "/workos-integration/integrations";
|
|
140
|
+
readonly WEBHOOK_SECRET: "/workos-integration/webhook-secret";
|
|
141
|
+
};
|
|
142
|
+
readonly ATTIO: {
|
|
143
|
+
readonly INTEGRATIONS: "/attio/integrations";
|
|
144
|
+
readonly OAUTH_CALLBACK: "/attio/oauth/callback";
|
|
145
|
+
readonly OBJECTS: {
|
|
146
|
+
readonly pattern: "/attio/integrations/:integrationId/objects";
|
|
147
|
+
readonly build: (integrationId: string) => string;
|
|
148
|
+
readonly params: {
|
|
149
|
+
readonly integrationId: "string";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
readonly AGENTS: {
|
|
154
|
+
readonly LIST: "/agents";
|
|
155
|
+
readonly RECENT: "/agents/recent";
|
|
156
|
+
readonly BY_ID: {
|
|
157
|
+
readonly pattern: "/agents/:id";
|
|
158
|
+
readonly build: (id: string) => string;
|
|
159
|
+
readonly params: {
|
|
160
|
+
readonly id: "string";
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
readonly TEMPLATES: "/templates";
|
|
165
|
+
readonly PUBLIC: {
|
|
166
|
+
readonly TEMPLATES: "/public/templates";
|
|
167
|
+
};
|
|
168
|
+
readonly TOOLS: {
|
|
169
|
+
readonly THAT_REQUIRE_APPROVALS: "/tools/that-require-approvals";
|
|
170
|
+
};
|
|
171
|
+
readonly INTEGRATIONS: {
|
|
172
|
+
readonly INSTALLATION_DETAILS_BY_TYPE: {
|
|
173
|
+
readonly pattern: "/integrations/:integrationType/installation-details";
|
|
174
|
+
readonly build: (integrationType: string) => string;
|
|
175
|
+
readonly params: {
|
|
176
|
+
readonly integrationType: "string";
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
readonly LIST: "/integrations";
|
|
180
|
+
readonly ACTIVE: "/integrations/active";
|
|
181
|
+
};
|
|
182
|
+
readonly NOTIFICATION_DESTINATIONS: {
|
|
183
|
+
readonly LIST: "/notification-destinations";
|
|
184
|
+
readonly BY_ID: {
|
|
185
|
+
readonly pattern: "/notification-destinations/:id";
|
|
186
|
+
readonly build: (id: string) => string;
|
|
187
|
+
readonly params: {
|
|
188
|
+
readonly id: "string";
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
readonly API_TOKENS: {
|
|
193
|
+
readonly LIST: "/api-tokens";
|
|
194
|
+
readonly BY_ID: {
|
|
195
|
+
readonly pattern: "/api-tokens/:id";
|
|
196
|
+
readonly build: (id: string) => string;
|
|
197
|
+
readonly params: {
|
|
198
|
+
readonly id: "string";
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
readonly SDK: {
|
|
203
|
+
readonly ME: "/sdk/me";
|
|
204
|
+
readonly SAMPLE_EVENTS: "/sdk/sample-events";
|
|
205
|
+
readonly TOOL_EXECUTE: "/sdk/tool-execute";
|
|
206
|
+
readonly TOOL_DEFINITIONS: "/sdk/tool-definitions";
|
|
207
|
+
readonly AGENT_RUN: "/sdk/agent-run";
|
|
208
|
+
readonly SESSION_EVENTS: "/sdk/session-events";
|
|
209
|
+
readonly DEPLOY: "/sdk/deploy";
|
|
210
|
+
};
|
|
211
|
+
readonly WEBHOOKS: {
|
|
212
|
+
readonly GMAIL: "/webhooks/gmail";
|
|
213
|
+
readonly FIGMA: "/webhooks/figma";
|
|
214
|
+
readonly WORKOS: "/webhooks/workos";
|
|
215
|
+
readonly JIRA_BY_ACCOUNT_ID: {
|
|
216
|
+
readonly pattern: "/webhooks/jira/:accountId";
|
|
217
|
+
readonly build: (accountId: string) => string;
|
|
218
|
+
readonly params: {
|
|
219
|
+
readonly accountId: "string";
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
readonly LINEAR_BY_USER_ID: {
|
|
223
|
+
readonly pattern: "/webhooks/linear/:userId";
|
|
224
|
+
readonly build: (userId: string) => string;
|
|
225
|
+
readonly params: {
|
|
226
|
+
readonly userId: "string";
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
readonly SCHEDULE_BY_INPUT_ID: {
|
|
230
|
+
readonly pattern: "/webhooks/schedule/:inputId";
|
|
231
|
+
readonly build: (inputId: string) => string;
|
|
232
|
+
readonly params: {
|
|
233
|
+
readonly inputId: "string";
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
readonly WORKOS_TRIGGER_BY_INTEGRATION_ID: {
|
|
237
|
+
readonly pattern: "/webhooks/workos-trigger/:integrationId";
|
|
238
|
+
readonly build: (integrationId: string) => string;
|
|
239
|
+
readonly params: {
|
|
240
|
+
readonly integrationId: "string";
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
readonly SCHEDULE: {
|
|
245
|
+
readonly TRIGGER_BY_INPUT_ID: {
|
|
246
|
+
readonly pattern: "/schedule/trigger/:inputId";
|
|
247
|
+
readonly build: (inputId: string) => string;
|
|
248
|
+
readonly params: {
|
|
249
|
+
readonly inputId: "string";
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
readonly REFRESH_TOKENS: "/refresh-tokens";
|
|
254
|
+
readonly USERS: {
|
|
255
|
+
readonly CREATE: "/users";
|
|
256
|
+
readonly BY_ID: {
|
|
257
|
+
readonly pattern: "/users/:id";
|
|
258
|
+
readonly build: (id: string) => string;
|
|
259
|
+
readonly params: {
|
|
260
|
+
readonly id: "string";
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
readonly BUILDER_CHAT: {
|
|
265
|
+
readonly HISTORY_BY_SESSION_ID: {
|
|
266
|
+
readonly pattern: "/builder-chat/:sessionId/history";
|
|
267
|
+
readonly build: (sessionId: string) => string;
|
|
268
|
+
readonly params: {
|
|
269
|
+
readonly sessionId: "string";
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=ApiRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiRoutes.d.ts","sourceRoot":"","sources":["../../src/shared/ApiRoutes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;6CAyBc,MAAM;;;;;;;;;;;;sCAcb,MAAM;;;;;;;oCAKR,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CA0FE,MAAM;;;;;;;4CAKN,MAAM,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;4CAuB1B,MAAM;;;;;;;;;;;iCAWjB,MAAM;;;;;;;;;;;;;;;;8CAoBO,MAAM;;;;;;;;;;;;iCAYnB,MAAM;;;;;;;;;;iCAUN,MAAM;;;;;;;;;;;;;;;;;;;;;wCAuBC,MAAM;;;;;;;qCAKT,MAAM;;;;;;;sCAKL,MAAM;;;;;;;4CAKA,MAAM;;;;;;;;;sCASZ,MAAM;;;;;;;;;;;iCAaX,MAAM;;;;;;;;;wCASC,MAAM;;;;;;CAI3B,CAAA"}
|