@segmentstream/agent 0.13.0 → 0.15.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.
Files changed (61) hide show
  1. package/README.md +7 -1
  2. package/dist/_chunks/{build-metadata-BLeBanNg.mjs → build-metadata-CJlaXNhc.mjs} +1 -1
  3. package/dist/_chunks/{inbound-request-BXhiIph-.mjs → inbound-request-RIRNBxUC.mjs} +3 -0
  4. package/dist/_chunks/principal-MEMlG3EG.mjs +126 -0
  5. package/dist/extension/config.d.ts +11 -0
  6. package/dist/extension/config.mjs +60 -1
  7. package/dist/extension/hooks/authorization.mjs +2 -2
  8. package/dist/extension/lib/attachment-tools.mjs +1 -1
  9. package/dist/extension/lib/attachments.d.ts +2 -0
  10. package/dist/extension/lib/attachments.mjs +1 -0
  11. package/dist/extension/lib/build-metadata.mjs +1 -1
  12. package/dist/extension/lib/confirmations.mjs +1 -1
  13. package/dist/extension/lib/conversation-runtime.mjs +1 -1
  14. package/dist/extension/lib/deferred-confirmations.d.ts +2 -0
  15. package/dist/extension/lib/deferred-confirmations.mjs +21 -10
  16. package/dist/extension/lib/ontology-connection.d.ts +1 -0
  17. package/dist/extension/lib/ontology-connection.mjs +18 -12
  18. package/dist/extension/lib/ontology-gateway.mjs +9 -2
  19. package/dist/extension/lib/ontology-metadata-read.mjs +1 -1
  20. package/dist/extension/lib/ontology-tools.d.ts +11 -2
  21. package/dist/extension/lib/ontology-tools.mjs +29 -4
  22. package/dist/extension/lib/runtime-envelope.d.ts +28 -0
  23. package/dist/extension/lib/runtime-envelope.mjs +8 -0
  24. package/dist/extension/lib/stored-files.mjs +1 -1
  25. package/dist/extension/lib/telegram/adapter.mjs +41 -7
  26. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  27. package/dist/extension/lib/telegram/attachments-send.mjs +3 -3
  28. package/dist/extension/lib/telegram/callbacks.d.ts +18 -0
  29. package/dist/extension/lib/telegram/callbacks.mjs +155 -0
  30. package/dist/extension/lib/telegram/confirmation-expiry.mjs +2 -2
  31. package/dist/extension/lib/telegram/confirmations.mjs +4 -4
  32. package/dist/extension/lib/telegram/conversations.d.ts +3 -0
  33. package/dist/extension/lib/telegram/conversations.mjs +57 -12
  34. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  35. package/dist/extension/lib/telegram/deferred-confirmations.mjs +5 -5
  36. package/dist/extension/lib/telegram/files.mjs +2 -2
  37. package/dist/extension/lib/telegram/health.mjs +1 -1
  38. package/dist/extension/lib/telegram/images.mjs +1 -1
  39. package/dist/extension/lib/telegram/inbound-request.d.ts +7 -0
  40. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  41. package/dist/extension/lib/telegram/inbound.d.ts +5 -0
  42. package/dist/extension/lib/telegram/inbound.mjs +110 -16
  43. package/dist/extension/lib/telegram/lifecycle.mjs +15 -3
  44. package/dist/extension/lib/telegram/media-policy.mjs +1 -1
  45. package/dist/extension/lib/telegram/principal.d.ts +1 -0
  46. package/dist/extension/lib/telegram/principal.mjs +1 -49
  47. package/dist/extension/lib/telegram/sessions.d.ts +3 -1
  48. package/dist/extension/lib/telegram/silent.mjs +3 -3
  49. package/dist/extension/lib/telegram/structured-settings.d.ts +6 -0
  50. package/dist/extension/lib/telegram/structured-settings.mjs +12 -0
  51. package/dist/extension/lib/telegram/structured.d.ts +28 -0
  52. package/dist/extension/lib/telegram/structured.mjs +114 -0
  53. package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
  54. package/dist/extension/lib/telegram/voice.mjs +1 -1
  55. package/dist/extension/lib/telegram/workspace-action.d.ts +24 -0
  56. package/dist/extension/lib/telegram/workspace-action.mjs +29 -0
  57. package/dist/extension/model.mjs +1 -1
  58. package/dist/extension/tools/attachments_promote.mjs +6 -0
  59. package/dist/extension/tools/ontology.mjs +1 -1
  60. package/dist/extension/tools/questions_ask.mjs +1 -1
  61. package/package.json +2 -2
@@ -0,0 +1,24 @@
1
+ import type { SessionAuthContext } from "eve/context";
2
+ import type { RuntimeEnvelope } from "../runtime-envelope.js";
3
+ import type { Environment } from "../environment.js";
4
+ import type { RuntimeToken } from "../runtime-token.js";
5
+ export declare class WorkspaceActionAlreadyDispatched extends Error {
6
+ }
7
+ export interface WorkspaceActionHook {
8
+ readonly entity: string;
9
+ readonly action: string;
10
+ readonly contextVersion: 2;
11
+ }
12
+ /** A declared routine action, re-authorized as the verified member on every event. */
13
+ export declare function workspaceAction(input: {
14
+ readonly configuration: WorkspaceActionHook;
15
+ readonly principal: SessionAuthContext;
16
+ readonly memberId: string;
17
+ readonly input: Readonly<Record<string, unknown>>;
18
+ readonly envelope: RuntimeEnvelope;
19
+ readonly environment?: Environment;
20
+ readonly token?: RuntimeToken;
21
+ readonly fetch?: typeof fetch;
22
+ readonly signal?: AbortSignal;
23
+ readonly beforeDispatch?: () => Promise<void>;
24
+ }): Promise<Record<string, unknown>>;
@@ -0,0 +1,29 @@
1
+ import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
+ import { dirname as __eveDirname } from "node:path";
3
+ import { createRequire as __eveCreateRequire } from "node:module";
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
6
+ __eveCreateRequire(import.meta.url);
7
+ import { object } from "../confirmation-description.mjs";
8
+ import { needsConfirmation } from "../confirmations.mjs";
9
+ import { actionToolName, ontologyTools } from "../ontology-tools.mjs";
10
+ var WorkspaceActionAlreadyDispatched = class extends Error {};
11
+ async function workspaceAction(input) {
12
+ const action = actionToolName(input.configuration.entity, input.configuration.action);
13
+ const tools = ontologyTools({
14
+ ...input,
15
+ beforeCall: async (name) => {
16
+ if (name === action) await input.beforeDispatch?.();
17
+ }
18
+ });
19
+ if (needsConfirmation(await tools.labels(input.memberId, action, input.input, input.signal))) throw new Error("A Telegram workspace hook must be a permitted routine action.");
20
+ if (!await tools.supportsRuntimeSource(input.memberId, input.signal)) throw new Error("A Telegram workspace hook requires the runtime-source capability.");
21
+ const raw = await tools.rpc(input.memberId, "tools/call", {
22
+ name: action,
23
+ arguments: input.input
24
+ }, input.signal);
25
+ const envelope = object(raw.structuredContent);
26
+ if (object(envelope.validation).ok === false) throw new Error("The Telegram workspace hook rejected its event.");
27
+ return object(envelope.result ?? envelope);
28
+ }
29
+ export { WorkspaceActionAlreadyDispatched, workspaceAction };
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { isPreview } from "./lib/environment.mjs";
8
- import { rolesOf } from "./lib/telegram/principal.mjs";
8
+ import { a as rolesOf } from "../_chunks/principal-MEMlG3EG.mjs";
9
9
  import { defineDynamic } from "eve";
10
10
  function chooseModel(input) {
11
11
  const { choice } = input;
@@ -4,6 +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 { u as runtimeEnvelope } from "../../_chunks/principal-MEMlG3EG.mjs";
7
8
  import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DVQBWK8p.mjs";
8
9
  import segmentstream from "../extension.mjs";
9
10
  import { actionApproval } from "../lib/confirmations.mjs";
@@ -73,6 +74,11 @@ var attachments_promote_default = defineTool({
73
74
  const recordId = optionalString(input, "record_id");
74
75
  const actionInput = optionalObject(input, "input");
75
76
  const promoted = await toolAttachments().promote(owner, stringArgument(input, "id"), {
77
+ runtime: runtimeEnvelope({
78
+ principal: ctx.session.auth.current,
79
+ sessionId: ctx.session.id,
80
+ callId: ctx.callId
81
+ }),
76
82
  entity: stringArgument(input, "entity"),
77
83
  action: stringArgument(input, "action"),
78
84
  ...actionInput === void 0 ? {} : { input: actionInput },
@@ -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 { memberIdOf } from "../lib/telegram/principal.mjs";
7
+ import { i as memberIdOf } from "../../_chunks/principal-MEMlG3EG.mjs";
8
8
  import segmentstream from "../extension.mjs";
9
9
  import { executeDeferredTool } from "../lib/deferred-confirmations.mjs";
10
10
  import { ontologyInspect, ontologyMetadata } from "../lib/ontology-gateway.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 { memberIdOf } from "../lib/telegram/principal.mjs";
7
+ import { i as memberIdOf } from "../../_chunks/principal-MEMlG3EG.mjs";
8
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/agent",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
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.49.0",
65
+ "@segmentstream-cloud/ontology": "0.50.1",
66
66
  "@vercel/oidc": "^3.8.4",
67
67
  "ai": "^7.0.128",
68
68
  "csv-parse": "^7.0.3",