@segmentstream/agent 0.12.1 → 0.12.2

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.
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- var version = "0.12.1";
7
+ var version = "0.12.2";
8
8
  function agentBuild(environment = process.env) {
9
9
  return {
10
10
  agent: version,
@@ -12,9 +12,26 @@ function makeRedactor(values = []) {
12
12
  return (input) => {
13
13
  let text = input;
14
14
  for (const value of secrets) text = text.replaceAll(value, "[REDACTED]");
15
- return redactPrivateKeys(text).replace(/\bsscli_(?:access_|key_)?v1\.[a-f0-9-]{36}\.[A-Za-z0-9_-]{43}\b/gi, "[REDACTED CLI CREDENTIAL]").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9+/_=.:~-]+/gi, "[REDACTED AUTHORIZATION]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, "[REDACTED JWT]").replace(/\b(?:sk|rk|vercel_blob_rw|vercel_blob_r|access_token|refresh_token)_[A-Za-z0-9._~-]{8,}/g, "[REDACTED]").replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@]+@/gi, "$1[REDACTED]@").replace(/([?&](?:access_token|api_key|apikey|key|password|refresh_token|secret|token|signature|sig)=)[^&#\s]*/gi, "$1[REDACTED]").replace(/((?:["']?)(?:password|passwd|credential|secret|client_secret|api_key|access_token|refresh_token|authorization|cookie|set-cookie|token)(?:["']?)\s*[:=]\s*)(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;})]+)/gi, "$1[REDACTED]").replace(/(Key\s*\([^)]*\)\s*=\s*)\([^)]*\)/gi, "$1([REDACTED])").replace(/(invalid input syntax for [^:]+:\s*)"[^"]*"/gi, "$1[REDACTED]");
15
+ return redactCopyContext(redactPrivateKeys(text)).replace(/\b(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?):\/\/\S+/gi, "[REDACTED CONNECTION URI]").replace(/\bsscli_(?:access_|key_)?v1\.[a-f0-9-]{36}\.[A-Za-z0-9_-]{43}\b/gi, "[REDACTED CLI CREDENTIAL]").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9+/_=.:~-]+/gi, "[REDACTED AUTHORIZATION]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, "[REDACTED JWT]").replace(/\b(?:sk|rk|vercel_blob_rw|vercel_blob_r|access_token|refresh_token)_[A-Za-z0-9._~-]{8,}/g, "[REDACTED]").replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@]+@/gi, "$1[REDACTED]@").replace(/([?&](?:access_token|api_key|apikey|key|password|refresh_token|secret|token|signature|sig)=)[^&#\s]*/gi, "$1[REDACTED]").replace(/((?:["']?)(?:password|passwd|credential|secret|client_secret|api_key|access_token|refresh_token|authorization|cookie|set-cookie|token)(?:["']?)\s*[:=]\s*)(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;})]+)/gi, "$1[REDACTED]").replace(/(Key\s*\([^)]*\)\s*=\s*)\([\s\S]*/gi, (match, prefix) => {
16
+ const end = Math.max(...[") already exists", ") is not present"].map((ending) => match.lastIndexOf(ending)));
17
+ return `${prefix}([REDACTED])${end < 0 ? "" : match.slice(end + 1)}`;
18
+ }).replace(/(Failing row contains\s+)[\s\S]*/gi, "$1[REDACTED]").replace(/(SQL statement\s+)[\s\S]*/gi, "$1[REDACTED]").replace(/(JSON data, line \d+:\s*)[\s\S]*/gi, "$1[REDACTED]").replace(/((?:Token|Escape sequence|but found)\s+")[\s\S]*/gi, (match, prefix) => {
19
+ const end = Math.max(match.lastIndexOf("\" is invalid"), match.lastIndexOf("\"."));
20
+ return `${prefix}[REDACTED]${end < 0 ? "\"" : match.slice(end)}`;
21
+ }).replace(/(invalid input syntax for [^:]+:\s*)"[^"]*"/gi, "$1[REDACTED]");
16
22
  };
17
23
  }
24
+ function redactCopyContext(text) {
25
+ const lines = /\bCOPY [^\n]*/gi;
26
+ let line;
27
+ while ((line = lines.exec(text)) !== null) {
28
+ const position = line[0].indexOf(", line ");
29
+ if (position < 0) continue;
30
+ const header = /^, line \d+(?:, column [^:\n]+)?:\s*/i.exec(line[0].slice(position));
31
+ return text.slice(0, line.index + (header ? position + header[0].length : 5)) + "[REDACTED]";
32
+ }
33
+ return text;
34
+ }
18
35
  function environmentSecrets(env) {
19
36
  return Object.entries(env).filter(([key]) => /(?:TOKEN|SECRET|PASSWORD|PRIVATE_KEY|API_KEY|COOKIE|SIGNING_KEY|DATABASE_URL|POSTGRES_URL|GRANT)/i.test(key)).map(([, value]) => value);
20
37
  }
@@ -53,6 +70,12 @@ const FIELDS = [
53
70
  "path",
54
71
  "retryable",
55
72
  "constraint",
73
+ "detail",
74
+ "hint",
75
+ "table",
76
+ "column",
77
+ "where",
78
+ "position",
56
79
  "sqlState",
57
80
  "field",
58
81
  "expected",
@@ -91,6 +114,61 @@ function property(value, key) {
91
114
  function scalar(value) {
92
115
  return typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
93
116
  }
117
+ function effectCause(value) {
118
+ if (property(value, "~effect/Cause") === "~effect/Cause") {
119
+ const reasons = property(value, "reasons");
120
+ if (Array.isArray(reasons)) return {
121
+ type: "EffectCause",
122
+ message: "Effect execution failed",
123
+ children: reasons.slice(0, MAX_NODES).map((error) => ({
124
+ error,
125
+ relation: "concurrent"
126
+ })),
127
+ limited: reasons.length > MAX_NODES
128
+ };
129
+ }
130
+ const legacy = property(value, Symbol.for("effect/Cause")) !== void 0;
131
+ if (!legacy && property(value, "~effect/Cause/Reason") !== "~effect/Cause/Reason") return void 0;
132
+ const type = property(value, "_tag");
133
+ switch (type) {
134
+ case "Fail": return {
135
+ type,
136
+ message: "Typed failure",
137
+ children: [{
138
+ error: property(value, "error"),
139
+ relation: "cause"
140
+ }]
141
+ };
142
+ case "Die": return {
143
+ type,
144
+ message: "Unexpected defect",
145
+ children: [{
146
+ error: property(value, "defect"),
147
+ relation: "cause"
148
+ }]
149
+ };
150
+ case "Interrupt": return {
151
+ type,
152
+ message: "Fiber interrupted",
153
+ children: []
154
+ };
155
+ case "Empty": return legacy ? {
156
+ type,
157
+ message: "Empty Effect cause",
158
+ children: []
159
+ } : void 0;
160
+ case "Sequential":
161
+ case "Parallel": return legacy ? {
162
+ type,
163
+ message: `${type} Effect causes`,
164
+ children: ["left", "right"].map((key) => ({
165
+ error: property(value, key),
166
+ relation: type === "Parallel" ? "concurrent" : "cause"
167
+ }))
168
+ } : void 0;
169
+ default: return;
170
+ }
171
+ }
94
172
  function ownValues(value) {
95
173
  if (!value || typeof value !== "object") return [];
96
174
  try {
@@ -118,6 +196,9 @@ function schemaInputRedactions(root) {
118
196
  for (const secret of failureRedactions.get(value) ?? []) if (secret) values.add(secret);
119
197
  }
120
198
  if (property(value, "_tag") === "SchemaError" || property(value, "name") === "SchemaError") issues.push(property(value, "issue"));
199
+ const effect = effectCause(value);
200
+ if (effect?.limited) limited = true;
201
+ if (effect) errors.push(...effect.children.map((child) => child.error));
121
202
  const explicit = property(value, links);
122
203
  if (Array.isArray(explicit)) {
123
204
  if (explicit.length > MAX_NODES) limited = true;
@@ -249,8 +330,9 @@ function createFailureReport(error, options) {
249
330
  if (Array.isArray(inheritedOmissions)) {
250
331
  for (const reason of inheritedOmissions.slice(0, 128)) if (typeof reason === "string") omissions.add(clean(reason));
251
332
  }
252
- const name = property(value, "_tag") ?? property(value, "name");
253
- const message = property(value, "message");
333
+ const effect = effectCause(value);
334
+ const name = property(value, "_tag") ?? property(value, "name") ?? effect?.type;
335
+ const message = property(value, "message") ?? effect?.message;
254
336
  const node = {
255
337
  id,
256
338
  type: typeof name === "string" ? clean(name) : "NonErrorThrow",
@@ -271,7 +353,8 @@ function createFailureReport(error, options) {
271
353
  if (scalar(field)) details[key] = (key === "expected" || key === "actual") && isSensitiveField(String(property(value, "field") ?? "")) ? "[REDACTED]" : typeof field === "string" ? clean(field) : field;
272
354
  }
273
355
  if (Object.keys(details).length) node.details = details;
274
- const children = [];
356
+ const children = effect?.children ?? [];
357
+ if (effect?.limited) omissions.add("Effect cause exceeded 1024 reasons");
275
358
  const explicit = property(value, links);
276
359
  if (Array.isArray(explicit)) {
277
360
  for (const item of explicit.slice(0, MAX_NODES)) {
@@ -4,5 +4,5 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { t as agentBuild } from "../../_chunks/build-metadata-Dl-ZJp5p.mjs";
7
+ import { t as agentBuild } from "../../_chunks/build-metadata-CLprTpsn.mjs";
8
8
  export { agentBuild };
@@ -6,7 +6,7 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { proxyEnvironment } from "./environment.mjs";
8
8
  import { runtimeToken } from "./runtime-token.mjs";
9
- import { r as workflowValue } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
9
+ import { r as workflowValue } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
10
10
  function collapseConversationEvents(events) {
11
11
  const latest = new Map();
12
12
  for (const event of events) {
@@ -13,7 +13,7 @@ import { decisionRouter } from "../group-routing/router.mjs";
13
13
  import { runtimeToken } from "../runtime-token.mjs";
14
14
  import { conversations } from "../conversations.mjs";
15
15
  import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
16
- import { t as agentBuild } from "../../../_chunks/build-metadata-Dl-ZJp5p.mjs";
16
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CLprTpsn.mjs";
17
17
  import { confirmationLocale } from "./confirmation-text.mjs";
18
18
  import { telegramSendScope } from "./send-queue.mjs";
19
19
  import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-BrWspFw5.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { t as agentBuild } from "../../../_chunks/build-metadata-Dl-ZJp5p.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CLprTpsn.mjs";
8
8
  import { runtimeRequestFailure } from "./runtime-request.mjs";
9
9
  import { GET } from "eve/channels";
10
10
  const HEALTH_ROUTE = "/eve/v1/telegram/health";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { t as agentBuild } from "../../../_chunks/build-metadata-Dl-ZJp5p.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-CLprTpsn.mjs";
8
8
  import { object } from "../confirmation-description.mjs";
9
9
  import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-BrWspFw5.mjs";
10
10
  import { needsConfirmation } from "../confirmations.mjs";
@@ -4,5 +4,5 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult, r as workflowValue, t as toWorkflowSerializable } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult, r as workflowValue, t as toWorkflowSerializable } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  export { toWorkflowSerializable, workflowToolResult, workflowValue };
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import { ID_INPUT, attachmentForModel, attachmentOwner, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
9
9
  import { defineTool } from "eve/tools";
10
10
  var attachments_discard_default = defineTool({
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import { attachmentForModel, attachmentOwner, toolAttachments } from "../lib/attachment-tools.mjs";
9
9
  import { defineTool } from "eve/tools";
10
10
  var attachments_list_default = defineTool({
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import { actionApproval } from "../lib/confirmations.mjs";
9
9
  import { ontologyTools, promotionTarget } from "../lib/ontology-tools.mjs";
10
10
  import { attachmentForModel, attachmentOwner, optionalObject, optionalString, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import { ID_INPUT, attachmentOwner, headerArgument, optionalString, pageInteger, readOutput, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
9
9
  import { readStoredFile } from "../lib/stored-files.mjs";
10
10
  import { defineTool } from "eve/tools";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import segmentstream from "../extension.mjs";
9
9
  import { sendAttachments, sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
10
10
  import { defineTool } from "eve/tools";
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
7
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
8
  import { readSheets, typedTable } from "../lib/attachment-tables.mjs";
9
9
  import { queryTable } from "../lib/attachment-query.mjs";
10
10
  import { ID_INPUT, attachmentForModel, attachmentOwner, boundedResultPage, headerArgument, optionalString, pageInteger, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { memberIdOf } from "../lib/telegram/principal.mjs";
8
- import { n as workflowToolResult } from "../../_chunks/workflow-serializable-BxrXgxjc.mjs";
8
+ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
9
9
  import { pendingQuestions, questionKey } from "../lib/questions.mjs";
10
10
  import { stringArgument } from "../lib/attachment-tools.mjs";
11
11
  import { defineTool } from "eve/tools";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram through the workspace's connection.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@chat-adapter/telegram": "4.41.0",
65
- "@segmentstream-cloud/ontology": "0.48.1",
65
+ "@segmentstream-cloud/ontology": "0.48.2",
66
66
  "@vercel/oidc": "^3.8.4",
67
67
  "ai": "^7.0.128",
68
68
  "csv-parse": "^7.0.3",