@lunora/agent 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (81) hide show
  1. package/dist/channels.d.mts +36 -36
  2. package/dist/channels.d.ts +36 -36
  3. package/dist/channels.mjs +1 -181
  4. package/dist/component.d.mts +57 -68
  5. package/dist/component.d.ts +57 -68
  6. package/dist/component.mjs +2 -418
  7. package/dist/inbound.d.mts +20 -20
  8. package/dist/inbound.d.ts +20 -20
  9. package/dist/inbound.mjs +1 -32
  10. package/dist/index.d.mts +488 -491
  11. package/dist/index.d.ts +488 -491
  12. package/dist/index.mjs +1 -18
  13. package/dist/naming.d.mts +19 -19
  14. package/dist/naming.d.ts +19 -19
  15. package/dist/naming.mjs +1 -8
  16. package/dist/packem_shared/AGENT_MODULE-BXx-tSCe.mjs +1 -0
  17. package/dist/packem_shared/VoiceSessionDO-bNlFmRop.mjs +1 -0
  18. package/dist/packem_shared/adaptMcpResult-18G7zpFo.mjs +2 -0
  19. package/dist/packem_shared/agentAsTool-gH17BQ8M.mjs +1 -0
  20. package/dist/packem_shared/base64-B_qZ_Tyh.mjs +1 -0
  21. package/dist/packem_shared/braintrustTelemetry-CnOI5WAw.mjs +1 -0
  22. package/dist/packem_shared/branch-marker-DELZqEOQ.mjs +1 -0
  23. package/dist/packem_shared/buildModelMessages-Dm2wVNQy.mjs +5 -0
  24. package/dist/packem_shared/codeTool-DYJVy-bH.mjs +1 -0
  25. package/dist/packem_shared/collectAgenticMemoryTools-DBcP8dUa.mjs +1 -0
  26. package/dist/packem_shared/combineTelemetry-oLCV_EPV.mjs +1 -0
  27. package/dist/packem_shared/common-Dck97z3Y.mjs +1 -0
  28. package/dist/packem_shared/compileAgentWorkflow-Bzd8oR9X.mjs +1 -0
  29. package/dist/packem_shared/consoleTelemetry-CaoI-NGg.mjs +1 -0
  30. package/dist/packem_shared/createAgentContext-D1cXHQO2.mjs +1 -0
  31. package/dist/packem_shared/createAgentGenerate-D96dEdYw.mjs +3 -0
  32. package/dist/packem_shared/createDispatchRunner-EYOnoElU-CpVpdTXn.mjs +1 -0
  33. package/dist/packem_shared/defineAgent-D0VIzlhu.mjs +3 -0
  34. package/dist/packem_shared/defineSkill-DfJxCwfZ.mjs +1 -0
  35. package/dist/packem_shared/functionTool-CWHhkYqd.mjs +1 -0
  36. package/dist/packem_shared/graph-component-B2YmC2eL.mjs +2 -0
  37. package/dist/packem_shared/memory-DNRyyp1b.mjs +1 -0
  38. package/dist/packem_shared/normalizeEntityName-BQpyssvL.mjs +1 -0
  39. package/dist/packem_shared/otlpTelemetry-DcW9mOLV.mjs +1 -0
  40. package/dist/packem_shared/runAgentLoop-BHjAmXGh.mjs +3 -0
  41. package/dist/packem_shared/runVoiceTurn-DhN9Asnn.mjs +1 -0
  42. package/dist/packem_shared/sandboxComponent-CKDGyK4Y.mjs +1 -0
  43. package/dist/packem_shared/sentryTelemetry-Dr2aPuvl.mjs +1 -0
  44. package/dist/packem_shared/types.d-B6v0Hgi5.d.mts +1131 -0
  45. package/dist/packem_shared/types.d-B6v0Hgi5.d.ts +1131 -0
  46. package/dist/packem_shared/voice-turn-DzRKyf-x.mjs +1 -0
  47. package/dist/sandbox.d.mts +126 -126
  48. package/dist/sandbox.d.ts +126 -126
  49. package/dist/sandbox.mjs +1 -113
  50. package/dist/telemetry/index.d.mts +185 -104
  51. package/dist/telemetry/index.d.ts +185 -104
  52. package/dist/telemetry/index.mjs +1 -4
  53. package/package.json +8 -8
  54. package/dist/packem_shared/AGENT_MODULE-Dnt_-AAT.mjs +0 -24
  55. package/dist/packem_shared/VoiceSessionDO-DLoXsHGF.mjs +0 -297
  56. package/dist/packem_shared/adaptMcpResult-wtNMvLoP.mjs +0 -65
  57. package/dist/packem_shared/agentAsTool-CUHlWsmt.mjs +0 -98
  58. package/dist/packem_shared/base64-BVwtgRJV.mjs +0 -18
  59. package/dist/packem_shared/braintrustTelemetry-wuGDErob.mjs +0 -47
  60. package/dist/packem_shared/buildModelMessages-BWFigaoo.mjs +0 -69
  61. package/dist/packem_shared/codeTool-CjgJOC9t.mjs +0 -122
  62. package/dist/packem_shared/collectAgenticMemoryTools-QrzpV-WX.mjs +0 -97
  63. package/dist/packem_shared/combineTelemetry-DCyaaWAI.mjs +0 -43
  64. package/dist/packem_shared/common-DAeFCot5.mjs +0 -61
  65. package/dist/packem_shared/compileAgentWorkflow-DX90058f.mjs +0 -55
  66. package/dist/packem_shared/consoleTelemetry-z2MiP1jt.mjs +0 -93
  67. package/dist/packem_shared/createAgentContext-4xJGXNR4.mjs +0 -50
  68. package/dist/packem_shared/createAgentGenerate-BQv9YJ01.mjs +0 -192
  69. package/dist/packem_shared/createDispatchRunner-DSbp_dph-ZHTtxy3f.mjs +0 -69
  70. package/dist/packem_shared/defineAgent-DAwAZC9P.mjs +0 -148
  71. package/dist/packem_shared/defineSkill-Ctf_S-rz.mjs +0 -22
  72. package/dist/packem_shared/functionTool-D6lCa2jB.mjs +0 -20
  73. package/dist/packem_shared/graph-component-Bbaxxymp.mjs +0 -217
  74. package/dist/packem_shared/memory-D4FPcBsX.mjs +0 -12
  75. package/dist/packem_shared/normalizeEntityName-BouctxLC.mjs +0 -3
  76. package/dist/packem_shared/runAgentLoop-B3Q2o-Uz.mjs +0 -493
  77. package/dist/packem_shared/runVoiceTurn-LnqLvCRR.mjs +0 -211
  78. package/dist/packem_shared/sandboxComponent-DR3pTwBL.mjs +0 -194
  79. package/dist/packem_shared/sentryTelemetry-CgqFJyLO.mjs +0 -36
  80. package/dist/packem_shared/types.d-BhJFTvz_.d.mts +0 -1114
  81. package/dist/packem_shared/types.d-BhJFTvz_.d.ts +0 -1114
@@ -1,194 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
- import { initLunora } from '@lunora/server';
3
- import { v } from '@lunora/values';
4
- import { t as toBase64 } from './base64-BVwtgRJV.mjs';
5
-
6
- const { internalAction } = initLunora.dataModel().create();
7
- const sandboxScrapeDocument = () => globalThis.document?.documentElement?.outerHTML ?? "";
8
- const MAX_FS_BYTES = 1e6;
9
- const MAX_LS_PAGES = 20;
10
- const fsEncoder = new TextEncoder();
11
- const runBrowserOp = async (browser, request) => {
12
- const url = request.url ?? "";
13
- switch (request.op) {
14
- case "content": {
15
- return browser.content(url);
16
- }
17
- case "pdf": {
18
- return { data: toBase64(await browser.pdf(url)), encoding: "base64", mediaType: "application/pdf" };
19
- }
20
- case "scrape": {
21
- return browser.scrape(url, sandboxScrapeDocument);
22
- }
23
- case "screenshot": {
24
- const bytes = await browser.screenshot(url, {
25
- ...request.fullPage === void 0 ? {} : { fullPage: request.fullPage },
26
- ...request.type === void 0 ? {} : { type: request.type }
27
- });
28
- return { data: toBase64(bytes), encoding: "base64", mediaType: request.type === "jpeg" ? "image/jpeg" : "image/png" };
29
- }
30
- default: {
31
- throw new LunoraError("INTERNAL", `@lunora/agent: sandbox browser op "${request.op}" is not supported`);
32
- }
33
- }
34
- };
35
- const runContainerOp = async (accessor, request) => {
36
- const handle = accessor.any();
37
- if (request.op === "exec") {
38
- const response = await handle.fetch("/exec", {
39
- body: JSON.stringify({ args: request.args ?? [], command: request.command ?? "" }),
40
- headers: { "content-type": "application/json" },
41
- method: "POST"
42
- });
43
- return response.text();
44
- }
45
- if (request.op === "fetch") {
46
- const response = await handle.fetch(request.path ?? "/", {
47
- ...request.body === void 0 ? {} : { body: request.body },
48
- method: request.method ?? "GET"
49
- });
50
- return response.text();
51
- }
52
- throw new LunoraError("INTERNAL", `@lunora/agent: sandbox container op "${request.op}" is not supported`);
53
- };
54
- const trimSlashes = (value) => {
55
- let start = 0;
56
- let end = value.length;
57
- while (start < end && value[start] === "/") {
58
- start += 1;
59
- }
60
- while (end > start && value[end - 1] === "/") {
61
- end -= 1;
62
- }
63
- return value.slice(start, end);
64
- };
65
- const resolveFsKey = (root, path) => {
66
- const base = trimSlashes(root);
67
- const segments = [];
68
- for (const segment of path.split("/")) {
69
- if (segment === "" || segment === ".") {
70
- continue;
71
- }
72
- if (segment === "..") {
73
- if (segments.length === 0) {
74
- throw new LunoraError("BAD_REQUEST", "@lunora/agent: fs path escapes the sandbox root");
75
- }
76
- segments.pop();
77
- continue;
78
- }
79
- segments.push(segment);
80
- }
81
- const relative = segments.join("/");
82
- return base && relative ? `${base}/${relative}` : base || relative;
83
- };
84
- const listFsEntries = async (bucket, key, base) => {
85
- const prefix = key.length > 0 ? `${key}/` : "";
86
- const strip = base.length > 0 ? base.length + 1 : 0;
87
- const entries = [];
88
- let cursor;
89
- for (let page = 0; page < MAX_LS_PAGES; page += 1) {
90
- const result = await bucket.list({ prefix, ...cursor === void 0 ? {} : { cursor } });
91
- for (const object of result.objects) {
92
- entries.push(object.key.slice(strip));
93
- }
94
- if (!result.truncated || result.cursor === void 0) {
95
- return { entries, truncated: false };
96
- }
97
- cursor = result.cursor;
98
- }
99
- return { entries, truncated: true };
100
- };
101
- const runFsOp = async (bucket, root, request) => {
102
- const base = trimSlashes(root);
103
- const key = resolveFsKey(root, request.path ?? "");
104
- switch (request.op) {
105
- case "ls": {
106
- const { entries, truncated } = await listFsEntries(bucket, key, base);
107
- return truncated ? { entries, truncated: true } : { entries };
108
- }
109
- case "read": {
110
- const head = await bucket.head(key);
111
- if (head && head.size > MAX_FS_BYTES) {
112
- throw new LunoraError(
113
- "BAD_REQUEST",
114
- `@lunora/agent: fs read: "${request.path ?? ""}" is ${String(head.size)} bytes (max ${String(MAX_FS_BYTES)})`
115
- );
116
- }
117
- const object = await bucket.get(key);
118
- if (!object) {
119
- throw new LunoraError("NOT_FOUND", `@lunora/agent: fs read: no file at "${request.path ?? ""}"`);
120
- }
121
- return object.text();
122
- }
123
- case "rm": {
124
- await bucket.delete(key);
125
- return { path: request.path ?? "", removed: true };
126
- }
127
- case "stat": {
128
- const head = await bucket.head(key);
129
- return head ? { exists: true, size: head.size } : { exists: false };
130
- }
131
- case "write": {
132
- const content = request.content ?? "";
133
- const bytes = fsEncoder.encode(content).length;
134
- if (bytes > MAX_FS_BYTES) {
135
- throw new LunoraError("BAD_REQUEST", `@lunora/agent: fs write: ${String(bytes)} bytes exceeds the max (${String(MAX_FS_BYTES)})`);
136
- }
137
- await bucket.put(key, content);
138
- return { bytes, path: request.path ?? "", wrote: true };
139
- }
140
- default: {
141
- throw new LunoraError("INTERNAL", `@lunora/agent: sandbox fs op "${request.op}" is not supported`);
142
- }
143
- }
144
- };
145
- const sandboxComponent = () => {
146
- const invoke = internalAction.input({
147
- args: v.optional(v.array(v.string())),
148
- body: v.optional(v.string()),
149
- bucket: v.optional(v.string()),
150
- command: v.optional(v.string()),
151
- content: v.optional(v.string()),
152
- fullPage: v.optional(v.boolean()),
153
- kind: v.union(v.literal("browser"), v.literal("container"), v.literal("fs")),
154
- method: v.optional(v.string()),
155
- name: v.optional(v.string()),
156
- op: v.string(),
157
- path: v.optional(v.string()),
158
- root: v.optional(v.string()),
159
- selector: v.optional(v.string()),
160
- type: v.optional(v.string()),
161
- url: v.optional(v.string())
162
- }).action(async ({ args, ctx: context }) => {
163
- const surface = context;
164
- const request = args;
165
- if (request.kind === "browser") {
166
- if (!surface.browser) {
167
- throw new LunoraError("INTERNAL", "@lunora/agent: sandbox browser op needs `ctx.browser` — install @lunora/browser and run codegen");
168
- }
169
- return runBrowserOp(surface.browser, request);
170
- }
171
- if (request.kind === "fs") {
172
- const bucket = surface.env?.[request.bucket ?? ""];
173
- if (!bucket || typeof bucket.get !== "function") {
174
- throw new LunoraError(
175
- "INTERNAL",
176
- `@lunora/agent: sandbox fs op found no R2 bucket "${request.bucket ?? ""}" on env — declare the r2_bucket binding in wrangler.jsonc and run codegen`
177
- );
178
- }
179
- return runFsOp(bucket, request.root ?? "", request);
180
- }
181
- const name = request.name ?? "";
182
- const accessor = surface.containers?.[name];
183
- if (!accessor) {
184
- throw new LunoraError(
185
- "INTERNAL",
186
- `@lunora/agent: sandbox container op found no ctx.containers["${name}"] — declare the container in lunora/containers.ts and run codegen`
187
- );
188
- }
189
- return runContainerOp(accessor, request);
190
- });
191
- return { invoke };
192
- };
193
-
194
- export { resolveFsKey, runFsOp, sandboxComponent };
@@ -1,36 +0,0 @@
1
- import { r as readField, t as toolInputOf } from './common-DAeFCot5.mjs';
2
-
3
- const stringOr = (value, fallback) => typeof value === "string" && value.length > 0 ? value : fallback;
4
- const sentryTelemetry = (options) => {
5
- const { functionId, recordInputs = false, Sentry: sentry } = options;
6
- return {
7
- executeLanguageModelCall: (options_) => {
8
- const attributes = {
9
- "gen_ai.operation.name": stringOr(functionId, "language_model_call"),
10
- "gen_ai.request.model": readField(options_, "modelId"),
11
- "gen_ai.system": readField(options_, "provider")
12
- };
13
- if (recordInputs) {
14
- attributes["gen_ai.prompt"] = readField(options_, "messages");
15
- }
16
- return sentry.startSpan({ attributes, name: stringOr(functionId, "language_model_call"), op: "gen_ai.generate" }, () => options_.execute());
17
- },
18
- executeTool: (options_) => {
19
- const toolName = readField(readField(options_, "toolCall"), "toolName");
20
- const attributes = {
21
- "gen_ai.operation.name": "execute_tool",
22
- "gen_ai.tool.call.id": readField(options_, "toolCallId"),
23
- "gen_ai.tool.name": toolName
24
- };
25
- if (recordInputs) {
26
- attributes["gen_ai.tool.input"] = toolInputOf(options_);
27
- }
28
- return sentry.startSpan({ attributes, name: `execute_tool ${stringOr(toolName, "tool")}`, op: "gen_ai.execute_tool" }, () => options_.execute());
29
- },
30
- onError: (error) => {
31
- sentry.captureException(error);
32
- }
33
- };
34
- };
35
-
36
- export { sentryTelemetry };