terse-types 0.0.21 → 0.0.23

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.
@@ -7,6 +7,11 @@ export var ChangeEventType;
7
7
  ChangeEventType["UPDATED"] = "UPDATED";
8
8
  ChangeEventType["ACTION_EXECUTED"] = "ACTION_EXECUTED";
9
9
  })(ChangeEventType || (ChangeEventType = {}));
10
+ const modelEventBaseSchema = z.object({
11
+ id: z.string(),
12
+ timestamp: z.number(),
13
+ response_id: z.string()
14
+ });
10
15
  export const changeEventTypeSchema = z.enum(ChangeEventType);
11
16
  export const sharedErrorContextSchema = z.object({
12
17
  error: z.unknown()
@@ -16,37 +21,23 @@ export const changedItemSchema = z.object({
16
21
  id: z.string(),
17
22
  change_event_type: changeEventTypeSchema
18
23
  });
19
- export const runErrorSchema = z.object({
24
+ export const runErrorSchema = modelEventBaseSchema.extend({
20
25
  type: z.literal("RunError"),
21
- id: z.string().optional(),
22
26
  error: z.string(),
23
- code: z.string().optional(),
24
- timestamp: z.number()
27
+ code: z.string().optional()
25
28
  });
26
- export const processOutputSchema = z.object({
29
+ export const processOutputSchema = modelEventBaseSchema.extend({
27
30
  type: z.literal("ProcessOutput"),
28
- id: z.string().optional(),
29
31
  stream: z.enum(["stdout", "stderr"]),
30
32
  content: z.string(),
31
- label: z.string(),
32
- timestamp: z.number()
33
+ label: z.string()
33
34
  });
34
- export const cancelledSchema = z.object({
35
+ export const cancelledSchema = modelEventBaseSchema.extend({
35
36
  type: z.literal("Cancelled"),
36
- id: z.string().optional(),
37
- reason: z.string().optional(),
38
- timestamp: z.number()
39
- });
40
- export const functionCallSchema = z.object({
41
- function_name: z.string(),
42
- result: z.string(),
43
- step_id: z.string()
37
+ reason: z.string().optional()
44
38
  });
45
- export const naturalStopSchema = z.object({
46
- step_id: z.string(),
47
- type: z.literal("NaturalStop"),
48
- id: z.string().optional(),
49
- timestamp: z.number()
39
+ export const naturalStopSchema = modelEventBaseSchema.extend({
40
+ type: z.literal("NaturalStop")
50
41
  });
51
42
  export const sendModelRequestSchema = z.object({
52
43
  type: z.literal("SendModelRequest"),
@@ -57,50 +48,28 @@ export const sendModelRequestSchema = z.object({
57
48
  client_turn_id: z.string(),
58
49
  template_id: z.string().optional()
59
50
  });
60
- export const toolApprovalResponseSchema = z.object({
61
- step_id: z.string(),
62
- type: z.literal("ToolApprovalResponse"),
63
- id: z.string().optional(),
51
+ export const toolApprovalResponseSchema = modelEventBaseSchema.extend({
64
52
  approved: z.boolean(),
65
53
  rejection_reason: z.string().optional(),
66
- timestamp: z.number()
54
+ type: z.literal("ToolApprovalResponse")
67
55
  });
68
- export const toolApprovalRequestSchema = z.object({
69
- step_id: z.string(),
70
- type: z.literal("ToolApprovalRequest"),
71
- id: z.string().optional(),
56
+ export const toolApprovalRequestSchema = modelEventBaseSchema.extend({
72
57
  name: z.string(),
73
58
  arguments: z.string(),
74
- timestamp: z.number()
59
+ type: z.literal("ToolApprovalRequest")
75
60
  });
76
- export const textDeltaSchema = z.object({
61
+ export const textDeltaSchema = modelEventBaseSchema.extend({
77
62
  delta: z.string(),
78
- step_id: z.string(),
79
- type: z.literal("TextDelta"),
80
- id: z.string().optional(),
81
- timestamp: z.number()
63
+ type: z.literal("TextDelta")
82
64
  });
83
- export const toolCallGeneratingSchema = z.object({
84
- tool_name: z.string(),
85
- step_id: z.string(),
86
- type: z.literal("ToolCallGenerating"),
87
- id: z.string().optional(),
88
- timestamp: z.number()
89
- });
90
- export const toolCallSchema = z.object({
65
+ export const toolCallSchema = modelEventBaseSchema.extend({
91
66
  summary: z.string(),
92
- step_id: z.string(),
93
- type: z.literal("ToolCall"),
94
- id: z.string().optional(),
95
67
  parameters: z.string(),
96
68
  integration: z.string(),
97
- timestamp: z.number()
69
+ type: z.literal("ToolCall")
98
70
  });
99
- export const thinkingSchema = z.object({
100
- step_id: z.string(),
101
- type: z.literal("Thinking"),
102
- id: z.string().optional(),
103
- timestamp: z.number()
71
+ export const thinkingSchema = modelEventBaseSchema.extend({
72
+ type: z.literal("Thinking")
104
73
  });
105
74
  export var ToolCallExecutionStatus;
106
75
  (function (ToolCallExecutionStatus) {
@@ -110,27 +79,21 @@ export var ToolCallExecutionStatus;
110
79
  ToolCallExecutionStatus["UNKNOWN"] = "unknown";
111
80
  })(ToolCallExecutionStatus || (ToolCallExecutionStatus = {}));
112
81
  export const toolCallExecutionStatusSchema = z.enum(ToolCallExecutionStatus);
113
- export const toolCallCompleteSchema = z.object({
82
+ export const toolCallCompleteSchema = modelEventBaseSchema.extend({
114
83
  tool_name: z.string(),
115
- timestamp: z.number(),
116
84
  status: toolCallExecutionStatusSchema,
117
- step_id: z.string(),
118
85
  type: z.literal("ToolCallComplete"),
119
- id: z.string().optional(),
120
86
  changed_items: z.array(changedItemSchema),
121
87
  integration: z.string(),
122
88
  url: z.string().optional(),
123
89
  result: z.string().optional(),
124
90
  errorContext: sharedErrorContextSchema.optional()
125
91
  });
126
- export const filterResultSchema = z.object({
92
+ export const filterResultSchema = modelEventBaseSchema.extend({
127
93
  isRelevant: z.boolean(),
128
94
  reason: z.string(),
129
95
  confidence: z.number(),
130
- step_id: z.string(),
131
- type: z.literal("FilterResult"),
132
- id: z.string().optional(),
133
- timestamp: z.number()
96
+ type: z.literal("FilterResult")
134
97
  });
135
98
  export var SandboxStage;
136
99
  (function (SandboxStage) {
@@ -148,13 +111,10 @@ export const SANDBOX_STAGE_LABELS = {
148
111
  [SandboxStage.INSTALLING_CLI]: "Installing CLI",
149
112
  [SandboxStage.RUNNING]: "Running agent"
150
113
  };
151
- export const userMessageSchema = z.object({
114
+ export const userMessageSchema = modelEventBaseSchema.extend({
152
115
  type: z.literal("UserMessage"),
153
- id: z.string().optional(),
154
116
  message: z.string(),
155
- step_id: z.string(),
156
- client_turn_id: z.string(),
157
- timestamp: z.number()
117
+ client_turn_id: z.string()
158
118
  });
159
119
  export const multipleChoiceOptionSchema = z.object({
160
120
  label: z.string(),
@@ -189,7 +149,6 @@ export const imageSchema = z.object({
189
149
  export const snippetVariantSchema = z.discriminatedUnion("type", [buttonSchema, integrationPromptSchema, navigateSchema, multipleChoiceSchema, imageSchema]);
190
150
  const chatSnippetMetadataSchema = {
191
151
  id: z.string().optional(),
192
- step_id: z.string().optional(),
193
152
  selectedValue: z.string().optional()
194
153
  };
195
154
  export const chatSnippetSchema = z.discriminatedUnion("type", [
@@ -199,16 +158,13 @@ export const chatSnippetSchema = z.discriminatedUnion("type", [
199
158
  multipleChoiceSchema.extend(chatSnippetMetadataSchema),
200
159
  imageSchema.extend(chatSnippetMetadataSchema)
201
160
  ]);
202
- export const modelEventChatSnippetSchema = z.object({
161
+ export const modelEventChatSnippetSchema = modelEventBaseSchema.extend({
203
162
  type: z.literal("Snippet"),
204
- id: z.string().optional(),
205
- timestamp: z.number(),
206
163
  snippet: chatSnippetSchema
207
164
  });
208
165
  export const modelEventSchema = z.discriminatedUnion("type", [
209
166
  toolApprovalResponseSchema,
210
167
  toolApprovalRequestSchema,
211
- toolCallGeneratingSchema,
212
168
  toolCallSchema,
213
169
  toolCallCompleteSchema,
214
170
  textDeltaSchema,
@@ -17,11 +17,6 @@ export declare const SocketEvents: {
17
17
  readonly WORKOS_FORCE_LOGOUT: "workos:force:logout";
18
18
  readonly WORKOS_SESSION_UPDATED: "workos:session:updated";
19
19
  readonly WORKOS_ORG_UPDATED: "workos:org:updated";
20
- readonly BUILDER_CHAT_EVENT: "builder:chat:event";
21
- readonly BUILDER_CHAT_MESSAGE: "builder:chat:message";
22
- readonly BUILDER_CHAT_CANCEL: "builder:chat:cancel";
23
- readonly BUILDER_CHAT_APPROVAL: "builder:chat:approval";
24
- readonly BUILDER_CHAT_MULTIPLE_CHOICE_ANSWER: "builder:chat:multiple_choice_answer";
25
20
  };
26
21
  /**
27
22
  * Socket room name patterns and helpers
@@ -19,13 +19,7 @@ export const SocketEvents = {
19
19
  WORKOS_USER_UPDATED: "workos:user:updated",
20
20
  WORKOS_FORCE_LOGOUT: "workos:force:logout",
21
21
  WORKOS_SESSION_UPDATED: "workos:session:updated",
22
- WORKOS_ORG_UPDATED: "workos:org:updated",
23
- // Builder chat events
24
- BUILDER_CHAT_EVENT: "builder:chat:event",
25
- BUILDER_CHAT_MESSAGE: "builder:chat:message",
26
- BUILDER_CHAT_CANCEL: "builder:chat:cancel",
27
- BUILDER_CHAT_APPROVAL: "builder:chat:approval",
28
- BUILDER_CHAT_MULTIPLE_CHOICE_ANSWER: "builder:chat:multiple_choice_answer"
22
+ WORKOS_ORG_UPDATED: "workos:org:updated"
29
23
  };
30
24
  /**
31
25
  * Socket room name patterns and helpers
@@ -1,22 +1,3 @@
1
- import { INTEGRATION_METADATA } from "./Integrations.js";
2
- var PolledRunStatus;
3
- (function (PolledRunStatus) {
4
- PolledRunStatus["SUCCESS"] = "success";
5
- PolledRunStatus["FAILED"] = "failed";
6
- PolledRunStatus["CANCELLED"] = "cancelled";
7
- PolledRunStatus["SKIPPED"] = "skipped";
8
- PolledRunStatus["AWAITING_APPROVAL"] = "awaiting_approval";
9
- PolledRunStatus["IN_PROGRESS"] = "in_progress";
10
- })(PolledRunStatus || (PolledRunStatus = {}));
11
- /**
12
- * Helper to get a friendly integration name from params
13
- */
14
- function getIntegrationName(integrationType) {
15
- if (!integrationType)
16
- return "integration";
17
- const meta = INTEGRATION_METADATA[integrationType];
18
- return meta?.name || integrationType;
19
- }
20
1
  /** Truncate a string to maxLen characters with an ellipsis */
21
2
  function truncate(text, maxLen = 35) {
22
3
  return text.length > maxLen ? `${text.slice(0, maxLen)}…` : text;
@@ -33,24 +14,6 @@ function safeParseResult(result) {
33
14
  return undefined;
34
15
  }
35
16
  }
36
- function toPolledRunStatus(status) {
37
- switch (status) {
38
- case PolledRunStatus.SUCCESS:
39
- return PolledRunStatus.SUCCESS;
40
- case PolledRunStatus.FAILED:
41
- return PolledRunStatus.FAILED;
42
- case PolledRunStatus.CANCELLED:
43
- return PolledRunStatus.CANCELLED;
44
- case PolledRunStatus.SKIPPED:
45
- return PolledRunStatus.SKIPPED;
46
- case PolledRunStatus.AWAITING_APPROVAL:
47
- return PolledRunStatus.AWAITING_APPROVAL;
48
- case PolledRunStatus.IN_PROGRESS:
49
- return PolledRunStatus.IN_PROGRESS;
50
- default:
51
- return null;
52
- }
53
- }
54
17
  /**
55
18
  * Display configurations for all tools.
56
19
  * Each tool defines how it should be displayed in preparing, executing, and complete phases.
@@ -61,130 +24,6 @@ function toPolledRunStatus(status) {
61
24
  * - complete: The tool has finished — params and result are both available
62
25
  */
63
26
  const TOOL_DISPLAY_CONFIG = {
64
- // ===================
65
- // ChatAgent Tools
66
- // ===================
67
- applyAgent: {
68
- preparing: "Getting your workflow ready",
69
- executing: params => {
70
- const agent = params?.agent;
71
- const name = agent?.name;
72
- return name ? `Setting up "${truncate(name)}"` : "Setting up your workflow";
73
- },
74
- complete: params => {
75
- const agent = params?.agent;
76
- const name = agent?.name;
77
- return name ? `You're all set: "${truncate(name)}"` : "Your workflow is ready";
78
- }
79
- },
80
- promptForIntegration: {
81
- preparing: "Getting connection ready",
82
- executing: params => {
83
- const integration = getIntegrationName(params?.integration);
84
- return `Connecting ${integration}`;
85
- },
86
- complete: params => {
87
- const integration = getIntegrationName(params?.integration);
88
- return `${integration} is connected`;
89
- }
90
- },
91
- askSurveyQuestion: {
92
- preparing: "Quick question",
93
- executing: params => {
94
- const question = params?.question || "A quick question";
95
- return question.length > 40 ? `${question.slice(0, 40)}…` : question;
96
- },
97
- complete: (_params, result) => {
98
- if (!result)
99
- return "Answered";
100
- // Result may be a JSON-encoded string (e.g. "\"Option A\"") or a JSON object
101
- try {
102
- const parsed = JSON.parse(result);
103
- if (typeof parsed === "string")
104
- return truncate(parsed, 50);
105
- if (typeof parsed === "object" && parsed !== null) {
106
- const answer = parsed.text;
107
- if (typeof answer === "string")
108
- return truncate(answer, 50);
109
- return "Answered";
110
- }
111
- }
112
- catch {
113
- // raw string, use as-is
114
- }
115
- return `Answered: ${truncate(result, 50)}`;
116
- }
117
- },
118
- fetchResourcesForIntegration: {
119
- preparing: "Looking things up",
120
- executing: params => {
121
- const integration = getIntegrationName(params?.integrationType);
122
- return `Checking what's available in ${integration}`;
123
- },
124
- complete: params => {
125
- const integration = getIntegrationName(params?.integrationType);
126
- return `Found available options in ${integration}`;
127
- }
128
- },
129
- getSampleEvents: {
130
- preparing: "Finding recent examples",
131
- executing: params => {
132
- const integration = getIntegrationName(params?.integrationType);
133
- return `Getting recent examples from ${integration}`;
134
- },
135
- complete: (params, result) => {
136
- const parsed = safeParseResult(result);
137
- const events = parsed?.events;
138
- const count = events?.length;
139
- const integration = getIntegrationName(params?.integrationType);
140
- if (count !== undefined && integration)
141
- return `Found ${count} recent example${count !== 1 ? "s" : ""} from ${integration}`;
142
- if (count !== undefined)
143
- return `Found ${count} recent example${count !== 1 ? "s" : ""}`;
144
- return `Found recent examples from ${integration}`;
145
- }
146
- },
147
- triggerAgentRun: {
148
- preparing: "Starting a run",
149
- executing: () => "Starting a run",
150
- complete: (_params, result) => {
151
- const parsed = safeParseResult(result);
152
- const name = parsed?.agentName;
153
- if (name)
154
- return `Started "${truncate(name)}"`;
155
- return "Run started";
156
- },
157
- approval: () => "Start this run?"
158
- },
159
- pollTriggeredRunStatus: {
160
- preparing: "Getting the latest progress",
161
- executing: () => "Checking progress",
162
- complete: (_params, result) => {
163
- const parsed = safeParseResult(result);
164
- const status = toPolledRunStatus(parsed?.status);
165
- const timedOut = parsed?.timedOut;
166
- const name = parsed?.agentName;
167
- if (timedOut) {
168
- return name ? `"${truncate(name)}" is still running` : "Still running";
169
- }
170
- switch (status) {
171
- case PolledRunStatus.SUCCESS:
172
- return name ? `"${truncate(name)}" finished` : "Finished";
173
- case PolledRunStatus.FAILED:
174
- return name ? `"${truncate(name)}" could not finish` : "Could not finish";
175
- case PolledRunStatus.CANCELLED:
176
- return name ? `"${truncate(name)}" was cancelled` : "Cancelled";
177
- case PolledRunStatus.SKIPPED:
178
- return name ? `"${truncate(name)}" was skipped` : "Skipped";
179
- case PolledRunStatus.AWAITING_APPROVAL:
180
- return name ? `"${truncate(name)}" needs approval` : "Needs approval";
181
- case PolledRunStatus.IN_PROGRESS:
182
- return name ? `"${truncate(name)}" is still running` : "Still running";
183
- default:
184
- return "Checked progress";
185
- }
186
- }
187
- },
188
27
  // ===================
189
28
  // Linear Tools
190
29
  // ===================
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./Entities.js";
7
7
  export * from "./FrontendRoutesBuilder.js";
8
8
  export * from "./Integrations.js";
9
9
  export * from "./InvalidationKeys.js";
10
+ export * from "./JsonSchemaUtils.js";
10
11
  export * from "./ModelEvents.js";
11
12
  export * from "./Notifications.js";
12
13
  export * from "./RunHistoryTypes.js";
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./Entities.js";
7
7
  export * from "./FrontendRoutesBuilder.js";
8
8
  export * from "./Integrations.js";
9
9
  export * from "./InvalidationKeys.js";
10
+ export * from "./JsonSchemaUtils.js";
10
11
  export * from "./ModelEvents.js";
11
12
  export * from "./Notifications.js";
12
13
  export * from "./RunHistoryTypes.js";