@lunora/agent 1.0.0-alpha.1 → 1.0.0-alpha.100

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 (92) hide show
  1. package/README.md +2 -0
  2. package/dist/channels.d.mts +33 -21
  3. package/dist/channels.d.ts +33 -21
  4. package/dist/channels.mjs +1 -181
  5. package/dist/component.d.mts +61 -56
  6. package/dist/component.d.ts +61 -56
  7. package/dist/component.mjs +2 -407
  8. package/dist/inbound.d.mts +23 -16
  9. package/dist/inbound.d.ts +23 -16
  10. package/dist/inbound.mjs +1 -32
  11. package/dist/index.d.mts +542 -409
  12. package/dist/index.d.ts +542 -409
  13. package/dist/index.mjs +1 -18
  14. package/dist/naming.d.mts +23 -10
  15. package/dist/naming.d.ts +23 -10
  16. package/dist/naming.mjs +1 -8
  17. package/dist/packem_shared/AGENT_MODULE-M4D1EejI.mjs +1 -0
  18. package/dist/packem_shared/VoiceSessionDO-D238XrlM.mjs +1 -0
  19. package/dist/packem_shared/adaptMcpResult-CVlq-_TO.mjs +2 -0
  20. package/dist/packem_shared/agent-loop-CE_Q6bk9.mjs +3 -0
  21. package/dist/packem_shared/agentAsTool-CgZb6ycK.mjs +1 -0
  22. package/dist/packem_shared/base64-5eyBfWO3.mjs +1 -0
  23. package/dist/packem_shared/braintrustTelemetry-Byne8uPK.mjs +1 -0
  24. package/dist/packem_shared/branch-marker-boZ00zmk.mjs +1 -0
  25. package/dist/packem_shared/buildModelMessages-Y4tGo1T9.mjs +5 -0
  26. package/dist/packem_shared/codeTool-BQb-K3my.mjs +1 -0
  27. package/dist/packem_shared/collectAgenticMemoryTools-BeMWT2qt.mjs +1 -0
  28. package/dist/packem_shared/combineTelemetry-DgE9W9G8.mjs +1 -0
  29. package/dist/packem_shared/common-CJSjtsfv.mjs +1 -0
  30. package/dist/packem_shared/compileAgentWorkflow-DVHi7NYD.mjs +1 -0
  31. package/dist/packem_shared/component-shared-G8ngerkU.mjs +1 -0
  32. package/dist/packem_shared/consoleTelemetry-BZY3Y-Ly.mjs +1 -0
  33. package/dist/packem_shared/createAgentContext-BvU9LP43.mjs +1 -0
  34. package/dist/packem_shared/createAgentGenerate-BOILDUZj.mjs +3 -0
  35. package/dist/packem_shared/createDispatchRunner-BxtGxAQi-DXXP7SxZ.mjs +1 -0
  36. package/dist/packem_shared/defineAgent-KgH-gwYg.mjs +3 -0
  37. package/dist/packem_shared/defineSkill-DGGvDWNq.mjs +1 -0
  38. package/dist/packem_shared/fnv1a-BNN96GYb.mjs +1 -0
  39. package/dist/packem_shared/functionTool-D3CP4f8-.mjs +1 -0
  40. package/dist/packem_shared/in-flight-calls-GH1A_1P3.mjs +1 -0
  41. package/dist/packem_shared/normalizeEntityName-k3fjicAG.mjs +2 -0
  42. package/dist/packem_shared/otlpTelemetry-ByqrB-72.mjs +1 -0
  43. package/dist/packem_shared/positive-integer-ztHqqpBk.mjs +1 -0
  44. package/dist/packem_shared/runAgentLoop-Drn1NcCc.mjs +1 -0
  45. package/dist/packem_shared/runVoiceTurn-BtcmyaBo.mjs +1 -0
  46. package/dist/packem_shared/sandboxComponent-BtOkUYpY.mjs +5 -0
  47. package/dist/packem_shared/sentryTelemetry-BHeydiAB.mjs +1 -0
  48. package/dist/packem_shared/tool-output-Cmk3JWMG.mjs +1 -0
  49. package/dist/packem_shared/types.d-B8WZl1rU.d.mts +1347 -0
  50. package/dist/packem_shared/types.d-B8WZl1rU.d.ts +1347 -0
  51. package/dist/packem_shared/voice-turn-BRj_it54.mjs +1 -0
  52. package/dist/reply.d.mts +40 -0
  53. package/dist/reply.d.ts +40 -0
  54. package/dist/reply.mjs +1 -0
  55. package/dist/sandbox.d.mts +130 -110
  56. package/dist/sandbox.d.ts +130 -110
  57. package/dist/sandbox.mjs +1 -109
  58. package/dist/skill-markdown.d.mts +36 -0
  59. package/dist/skill-markdown.d.ts +36 -0
  60. package/dist/skill-markdown.mjs +1 -0
  61. package/dist/telemetry/index.d.mts +319 -96
  62. package/dist/telemetry/index.d.ts +319 -96
  63. package/dist/telemetry/index.mjs +1 -4
  64. package/package.json +18 -9
  65. package/dist/packem_shared/AGENT_MODULE-Dnt_-AAT.mjs +0 -24
  66. package/dist/packem_shared/VoiceSessionDO-DLoXsHGF.mjs +0 -297
  67. package/dist/packem_shared/adaptMcpResult-wtNMvLoP.mjs +0 -65
  68. package/dist/packem_shared/agentAsTool-Dt8NlU6k.mjs +0 -94
  69. package/dist/packem_shared/base64-BVwtgRJV.mjs +0 -18
  70. package/dist/packem_shared/braintrustTelemetry-wuGDErob.mjs +0 -47
  71. package/dist/packem_shared/buildModelMessages-BWFigaoo.mjs +0 -69
  72. package/dist/packem_shared/codeTool-CjgJOC9t.mjs +0 -122
  73. package/dist/packem_shared/collectAgenticMemoryTools-QrzpV-WX.mjs +0 -97
  74. package/dist/packem_shared/combineTelemetry-DCyaaWAI.mjs +0 -43
  75. package/dist/packem_shared/common-DAeFCot5.mjs +0 -61
  76. package/dist/packem_shared/compileAgentWorkflow-BxJjHgtD.mjs +0 -55
  77. package/dist/packem_shared/consoleTelemetry-z2MiP1jt.mjs +0 -93
  78. package/dist/packem_shared/createAgentContext-4xJGXNR4.mjs +0 -50
  79. package/dist/packem_shared/createAgentGenerate-BQv9YJ01.mjs +0 -192
  80. package/dist/packem_shared/createDispatchRunner-DSbp_dph-ZHTtxy3f.mjs +0 -69
  81. package/dist/packem_shared/defineAgent-D6maSbVc.mjs +0 -148
  82. package/dist/packem_shared/defineSkill-Ctf_S-rz.mjs +0 -22
  83. package/dist/packem_shared/functionTool-D6lCa2jB.mjs +0 -20
  84. package/dist/packem_shared/graph-component-aoUwO-f0.mjs +0 -216
  85. package/dist/packem_shared/memory-D4FPcBsX.mjs +0 -12
  86. package/dist/packem_shared/normalizeEntityName-CyEEWFkR.mjs +0 -3
  87. package/dist/packem_shared/runAgentLoop-Dhg4ZNvw.mjs +0 -493
  88. package/dist/packem_shared/runVoiceTurn-LnqLvCRR.mjs +0 -211
  89. package/dist/packem_shared/sandboxComponent-DR3pTwBL.mjs +0 -194
  90. package/dist/packem_shared/sentryTelemetry-CgqFJyLO.mjs +0 -36
  91. package/dist/packem_shared/types.d-BWG0uUtX.d.mts +0 -1015
  92. package/dist/packem_shared/types.d-BWG0uUtX.d.ts +0 -1015
@@ -1,36 +1,41 @@
1
1
  import { Telemetry } from 'ai';
2
2
  /**
3
- * Privacy options shared by every telemetry integration in this package.
4
- *
5
- * Both flags default to **FALSE**. Without an explicit opt-in, no prompt,
6
- * message, tool input, generated model text, or tool output is ever forwarded
7
- * to a downstream tracer — only structural metadata (model id, finish reason,
8
- * token counts, tool name, timing, success/failure) is recorded. This is the
9
- * privacy-safe default: turn recording on deliberately, per integration.
10
- */
3
+ * Privacy options shared by every telemetry integration in this package.
4
+ *
5
+ * Both flags default to **FALSE**. Without an explicit opt-in, no prompt,
6
+ * message, tool input, generated model text, or tool output is ever forwarded
7
+ * to a downstream tracer — only structural metadata (model id, finish reason,
8
+ * token counts, tool name, timing, success/failure) is recorded. This is the
9
+ * privacy-safe default: turn recording on deliberately, per integration.
10
+ * @experimental
11
+ */
11
12
  interface CommonOptions {
12
13
  /**
13
- * When `true`, record model/tool **input** — prompts, messages, and tool
14
- * call arguments. Default `false`.
15
- */
14
+ * When `true`, record model/tool **input** — prompts, messages, and tool
15
+ * call arguments. Default `false`.
16
+ */
16
17
  recordInputs?: boolean;
17
18
  /**
18
- * When `true`, record model/tool **output** — generated text and tool
19
- * results. Default `false`.
20
- */
19
+ * When `true`, record model/tool **output** — generated text and tool
20
+ * results. Default `false`.
21
+ */
21
22
  recordOutputs?: boolean;
22
23
  }
23
- /** The span handle a {@link BraintrustLike.traced} callback receives. */
24
+ /**
25
+ * The span handle a {@link BraintrustLike.traced} callback receives.
26
+ * @experimental
27
+ */
24
28
  interface BraintrustSpan {
25
29
  /** Attach structured fields to the current span. */
26
30
  log: (event: Record<string, unknown>) => void;
27
31
  }
28
32
  /**
29
- * The minimal, **structural** slice of the `braintrust` SDK this bridge needs.
30
- * `braintrust` is intentionally **not** a dependency — the app passes its own
31
- * initialized logger, so this package stays dependency-free and works with any
32
- * compatible Braintrust SDK version.
33
- */
33
+ * The minimal, **structural** slice of the `braintrust` SDK this bridge needs.
34
+ * `braintrust` is intentionally **not** a dependency — the app passes its own
35
+ * initialized logger, so this package stays dependency-free and works with any
36
+ * compatible Braintrust SDK version.
37
+ * @experimental
38
+ */
34
39
  interface BraintrustLike {
35
40
  /** Run `callback` inside a new traced span and return its result. */
36
41
  traced: <T>(callback: (span: BraintrustSpan) => T, args?: {
@@ -38,113 +43,331 @@ interface BraintrustLike {
38
43
  type?: string;
39
44
  }) => T;
40
45
  }
41
- /** Options for {@link braintrustTelemetry}. */
46
+ /**
47
+ * Options for {@link braintrustTelemetry}.
48
+ * @experimental
49
+ */
42
50
  interface BraintrustTelemetryOptions extends CommonOptions {
43
51
  /** Span-name prefix for the language-model call (e.g. the agent name). */
44
52
  functionId?: string;
45
53
  /**
46
- * The caller's initialized Braintrust logger (dependency-injected). Import
47
- * and initialize `braintrust` in your app and pass it as `logger`.
48
- */
54
+ * The caller's initialized Braintrust logger (dependency-injected). Import
55
+ * and initialize `braintrust` in your app and pass it as `logger`.
56
+ */
49
57
  logger: BraintrustLike;
50
58
  }
51
59
  /**
52
- * A dependency-injected Braintrust bridge for the ai@7 telemetry surface.
53
- *
54
- * It wraps model calls (`type: "llm"`) and tool executions (`type: "tool"`) in
55
- * `logger.traced` spans and logs structural metadata. Prompts / tool arguments
56
- * are logged only when `recordInputs` is set; generated text / tool results
57
- * only when `recordOutputs` is set. `onError` opens a span and logs the error.
58
- *
59
- * The app owns Braintrust initialization; pass the logger in as `logger`.
60
- */
60
+ * A dependency-injected Braintrust bridge for the ai@7 telemetry surface.
61
+ *
62
+ * It wraps model calls (`type: "llm"`) and tool executions (`type: "tool"`) in
63
+ * `logger.traced` spans and logs structural metadata, including the call's token
64
+ * usage as Braintrust `metrics`. Prompts / tool arguments are logged only when
65
+ * `recordInputs` is set; generated text / tool results only when `recordOutputs`
66
+ * is set. `onError` opens a span and logs the error.
67
+ *
68
+ * The tool span is driven by the agent LOOP, not by `ai`: Lunora exposes tools
69
+ * schema-only so the SDK never executes one (see `telemetry/tool-execution.ts`).
70
+ *
71
+ * **A model-call span closes when the CALL ends, not when `execute()` resolves.**
72
+ * On a streamed turn `execute()` resolves the instant `doStream` hands back the
73
+ * stream — before a token, before any usage — so a span that simply awaited it
74
+ * measured time-to-first-byte and logged the stream handle instead of the
75
+ * generation. `execute()` still runs INSIDE the traced callback, which is what
76
+ * parents the provider's own work under the span; the callback then parks until
77
+ * the SDK's terminal event for that `callId` arrives, so `traced` finishes the
78
+ * span at the real end of the call, with the real usage. The caller gets
79
+ * `execute()`'s value the moment it resolves, exactly as before — the span's
80
+ * lifetime and the caller's are deliberately separate.
81
+ *
82
+ * The app owns Braintrust initialization; pass the logger in as `logger`.
83
+ * @experimental
84
+ */
61
85
  declare const braintrustTelemetry: (options: BraintrustTelemetryOptions) => Telemetry;
62
86
  /**
63
- * Combine several {@link Telemetry} integrations into a single one that fans
64
- * every lifecycle callback out to all of them and nests the two execution
65
- * wrappers so multiple span-context wrappers compose correctly.
66
- *
67
- * Value callbacks (`onStart`, `onStepEnd`, `onToolExecutionEnd`, …) invoke each
68
- * integration's matching callback (guarding `undefined`) and await them all in
69
- * parallel. The wrappers (`executeLanguageModelCall`, `executeTool`) are
70
- * composed by nesting right-to-left; integrations without a wrapper are skipped,
71
- * and with none defined the plain `execute` still runs.
72
- */
87
+ * Combine several {@link Telemetry} integrations into a single one that fans
88
+ * every lifecycle callback out to all of them and nests the two execution
89
+ * wrappers so multiple span-context wrappers compose correctly.
90
+ *
91
+ * Value callbacks (`onStart`, `onStepEnd`, `onToolExecutionEnd`, …) invoke each
92
+ * integration's matching callback (guarding `undefined`) and await them all in
93
+ * parallel. The wrappers (`executeLanguageModelCall`, `executeTool`) are
94
+ * composed by nesting right-to-left; integrations without a wrapper are skipped,
95
+ * and with none defined the plain `execute` still runs.
96
+ * @experimental
97
+ */
73
98
  declare const combineTelemetry: (...integrations: Telemetry[]) => Telemetry;
74
- /** Severity level passed to a {@link ConsoleLogger}. */
99
+ /**
100
+ * Severity level passed to a {@link ConsoleLogger}.
101
+ * @experimental
102
+ */
75
103
  type ConsoleLogLevel = "error" | "info" | "warn";
76
104
  /**
77
- * Structured log sink. Receives a level, a static human message, and a bag of
78
- * structured fields (never interpolated into the message, so log processors can
79
- * index them). The default sink writes to `globalThis.console`.
80
- */
105
+ * Structured log sink. Receives a level, a static human message, and a bag of
106
+ * structured fields (never interpolated into the message, so log processors can
107
+ * index them). The default sink writes to `globalThis.console`.
108
+ * @experimental
109
+ */
81
110
  type ConsoleLogger = (level: ConsoleLogLevel, message: string, fields: Record<string, unknown>) => void;
82
- /** Options for {@link consoleTelemetry}. */
111
+ /**
112
+ * Options for {@link consoleTelemetry}.
113
+ * @experimental
114
+ */
83
115
  interface ConsoleTelemetryOptions extends CommonOptions {
84
116
  /**
85
- * Identifier prefixed into every log message (e.g. the agent name). Helps
86
- * correlate lines when several agents share one process. Optional.
87
- */
117
+ * Identifier prefixed into every log message (e.g. the agent name). Helps
118
+ * correlate lines when several agents share one process. Optional.
119
+ */
88
120
  functionId?: string;
89
121
  /**
90
- * Sink for structured log lines. Defaults to a `globalThis.console`-backed
91
- * writer that routes `info`/`warn`/`error` to the matching console method.
92
- */
122
+ * Sink for structured log lines. Defaults to a `globalThis.console`-backed
123
+ * writer that routes `info`/`warn`/`error` to the matching console method.
124
+ */
93
125
  logger?: ConsoleLogger;
94
126
  }
95
127
  /**
96
- * A zero-dependency structured tracer for the ai@7 telemetry surface.
97
- *
98
- * It maps the generation lifecycle onto {@link ConsoleLogger} calls: operation
99
- * start/end, per-step start/end, model-call end (model + finish reason +
100
- * usage), and tool start/end (name, success, timing). By default it records
101
- * **only structural metadata** — set `recordInputs` to also log prompts / tool
102
- * arguments, and `recordOutputs` to log generated text / tool results.
103
- *
104
- * Every callback is defensive (event fields may be absent) and synchronous.
105
- */
128
+ * A zero-dependency structured tracer for the ai@7 telemetry surface.
129
+ *
130
+ * It maps the generation lifecycle onto {@link ConsoleLogger} calls: operation
131
+ * start/end, per-step start/end, model-call end (model + finish reason +
132
+ * usage), and tool start/end (name, success, timing). By default it records
133
+ * **only structural metadata** — set `recordInputs` to also log prompts / tool
134
+ * arguments, and `recordOutputs` to log generated text / tool results.
135
+ *
136
+ * Every callback is defensive (event fields may be absent) and synchronous.
137
+ * @experimental
138
+ */
106
139
  declare const consoleTelemetry: (options?: ConsoleTelemetryOptions) => Telemetry;
107
140
  /**
108
- * The minimal, **structural** slice of `@sentry/cloudflare` (equivalently
109
- * `@sentry/node`/`@sentry/browser`) this bridge needs. `@sentry/cloudflare` is
110
- * intentionally **not** a dependency — the app passes its own already-initialized
111
- * Sentry namespace, so this package stays dependency-free and works with any
112
- * compatible Sentry SDK version.
113
- */
141
+ * Options for {@link otlpTelemetry}.
142
+ * @experimental
143
+ */
144
+ interface OtlpTelemetryOptions extends CommonOptions {
145
+ /**
146
+ * Conversation / session id to tag each generation span with, emitted as the
147
+ * `gen_ai.conversation.id` semantic-convention attribute so a multi-turn
148
+ * conversation's model turns group in the trace store. On a deployed agent the
149
+ * platform wiring passes the run's `threadKey` here automatically (one thread =
150
+ * one conversation). Omitted → the attribute is absent (backward-compatible),
151
+ * and each turn's span is ungrouped.
152
+ */
153
+ conversationId?: string;
154
+ /**
155
+ * The OTLP-over-HTTP collector base endpoint (e.g. the Lunora Cloud's `/v1`
156
+ * base). Spans are POSTed to `${endpoint}/v1/traces`; a trailing slash is
157
+ * tolerated. On the platform this is the injected `LUNORA_OTLP_ENDPOINT`.
158
+ */
159
+ endpoint: string;
160
+ /**
161
+ * Extra headers merged onto every POST — typically the correlation headers
162
+ * the platform injects. `Content-Type: application/json` is set by default.
163
+ */
164
+ headers?: Record<string, string>;
165
+ /** `service.name` resource attribute on every span. Defaults to `lunora`. */
166
+ serviceName?: string;
167
+ /**
168
+ * Bearer token added as `Authorization: Bearer` (wins over any authorization
169
+ * in `headers`) — the injected `LUNORA_OTLP_TOKEN`. Omit for an
170
+ * unauthenticated collector.
171
+ */
172
+ token?: string;
173
+ /**
174
+ * Trace id (32-hex) to hang every span of this run under, so one agent run
175
+ * reads as one trace. Pass a stable id derived from the run (e.g. the
176
+ * workflow run id). Omitted → each span mints its own trace id (still valid,
177
+ * just ungrouped).
178
+ */
179
+ traceId?: string;
180
+ /**
181
+ * The Worker request's `waitUntil`, so a fire-and-forget export survives
182
+ * isolate teardown after the turn returns. Omit and the send degrades to
183
+ * best-effort.
184
+ */
185
+ waitUntil?: (promise: Promise<unknown>) => void;
186
+ }
187
+ /**
188
+ * An OTLP-over-HTTP telemetry integration for `@lunora/agent`.
189
+ *
190
+ * The OTLP counterpart to the `sentryTelemetry` / `braintrustTelemetry` bridges:
191
+ * it records each language-model call and each tool execution as an OTLP **span**
192
+ * (`gen_ai.*` semantic-convention attributes — model, provider, token usage,
193
+ * tool name) and ships it to a collector, so agent generations land in the same
194
+ * trace store as the rest of an app's telemetry (the Lunora Cloud, or any OTel
195
+ * collector). Plug it into `defineAgent({ telemetry: { isEnabled: true,
196
+ * integrations: [otlpTelemetry({ endpoint, token })] } })`.
197
+ *
198
+ * **A model-call span closes when the CALL ends, not when `execute()` resolves.**
199
+ * On a streamed turn `execute()` resolves the instant `doStream` hands back the
200
+ * stream — before a single token, before any usage, and before any mid-stream
201
+ * failure. Closing the span there reported every voice and workflow-streamed turn
202
+ * as a ~1 ms, zero-token, always-OK call. So the span opens in
203
+ * `executeLanguageModelCall` (which also owns the failure path, since a rejected
204
+ * provider call produces no end event) and closes on `onLanguageModelCallEnd`,
205
+ * which the SDK fires once the response is normalized — after the stream's
206
+ * `finish` part, where the duration and the token usage actually live.
207
+ * `onError` / `onAbort` close whatever is still open, so a stream that dies or is
208
+ * barged in on reports a failure instead of a phantom success.
209
+ *
210
+ * **Tool spans come from the agent loop.** Lunora exposes tools to the model
211
+ * schema-only, so `ai` never runs one and never fires its tool telemetry; the
212
+ * loop calls `executeTool` itself from the durable step where the tool really
213
+ * runs (see `telemetry/tool-execution.ts`).
214
+ *
215
+ * One span per REAL execution: the agent loop memoizes each `step.do(...)`, so a
216
+ * Workflow replay returns the cached result without re-invoking the wrapped work
217
+ * and no duplicate span is emitted. Privacy-safe by default —
218
+ * `recordInputs`/`recordOutputs` both default `false`, so no prompt or generated
219
+ * text leaves the worker without an explicit opt-in; only structural metadata +
220
+ * token counts are recorded.
221
+ *
222
+ * Each export is fire-and-forget (registered with `waitUntil` when supplied);
223
+ * every rejection is swallowed so a flaky collector never surfaces to the run.
224
+ *
225
+ * One deliberate difference from the SDK-backed bridges, which delegate to a host
226
+ * tracer: flat, not nested. Every span gets `traceId` (shared when `traceId` is
227
+ * set) but no `parentSpanId`, so model-call and tool spans are siblings under the
228
+ * run rather than a tree — OTLP has no ambient span context to parent to here.
229
+ * @param options `endpoint` (+ optional `token`/`headers`/`serviceName`),
230
+ * `traceId` to group a run's spans, `waitUntil`, and the `recordInputs`/
231
+ * `recordOutputs` privacy flags.
232
+ * @experimental
233
+ */
234
+ declare const otlpTelemetry: (options: OtlpTelemetryOptions) => Telemetry;
235
+ /** The span context both `startSpan` and `startSpanManual` are called with. */
236
+ interface SentrySpanContext {
237
+ attributes?: Record<string, unknown>;
238
+ name: string;
239
+ op?: string;
240
+ }
241
+ /**
242
+ * The subset of a Sentry `Span` this bridge drives. Structural, like
243
+ * {@link SentryLike} itself — a real `@sentry/*` span satisfies it.
244
+ * @experimental
245
+ */
246
+ interface SentrySpan {
247
+ /** Finish the span. Called once, from whichever terminal event closes the call. */
248
+ end: () => void;
249
+ /** Attach attributes discovered after the span started (token usage). */
250
+ setAttributes?: (attributes: Record<string, unknown>) => unknown;
251
+ /** `1` = OK, `2` = ERROR (Sentry's `SPAN_STATUS_OK` / `SPAN_STATUS_ERROR`). */
252
+ setStatus?: (status: {
253
+ code: 0 | 1 | 2;
254
+ message?: string;
255
+ }) => unknown;
256
+ }
257
+ /**
258
+ * The minimal, **structural** slice of `@sentry/cloudflare` (equivalently
259
+ * `@sentry/node`/`@sentry/browser`) this bridge needs. `@sentry/cloudflare` is
260
+ * intentionally **not** a dependency — the app passes its own already-initialized
261
+ * Sentry namespace, so this package stays dependency-free and works with any
262
+ * compatible Sentry SDK version.
263
+ * @experimental
264
+ */
114
265
  interface SentryLike {
115
266
  /** Capture a thrown value / exception. */
116
267
  captureException: (exception: unknown) => unknown;
117
- /** Run `callback` inside a new span and return its result. */
118
- startSpan: <T>(context: {
119
- attributes?: Record<string, unknown>;
120
- name: string;
121
- op?: string;
122
- }, callback: (span: {
123
- setStatus?: (status: {
124
- code: number;
125
- } | string) => void;
126
- }) => T) => T;
268
+ /** Run `callback` inside a new span, finished when the callback settles. */
269
+ startSpan: <T>(context: SentrySpanContext, callback: (span: SentrySpan) => T) => T;
270
+ /**
271
+ * Run `callback` inside a new span that is **not** finished automatically —
272
+ * the caller owns its lifetime through `span.end()`. Present on every Sentry
273
+ * SDK built on `@sentry/core` (verified against `@sentry/core@10.55.0`); it is
274
+ * what lets a streamed model call be measured to the end of the stream while
275
+ * still nesting the provider's own work under it.
276
+ */
277
+ startSpanManual: <T>(context: SentrySpanContext, callback: (span: SentrySpan) => T) => T;
127
278
  }
128
- /** Options for {@link sentryTelemetry}. */
279
+ /**
280
+ * Options for {@link sentryTelemetry}.
281
+ * @experimental
282
+ */
129
283
  interface SentryTelemetryOptions extends CommonOptions {
130
284
  /** Span-name prefix for the language-model call (e.g. the agent name). */
131
285
  functionId?: string;
132
286
  /**
133
- * The caller's already-initialized Sentry namespace (dependency-injected).
134
- * `import * as Sentry from "@sentry/cloudflare"` and pass it as `Sentry`.
135
- */
287
+ * The caller's already-initialized Sentry namespace (dependency-injected).
288
+ * `import * as Sentry from "@sentry/cloudflare"` and pass it as `Sentry`.
289
+ */
136
290
  Sentry: SentryLike;
137
291
  }
138
292
  /**
139
- * A dependency-injected Sentry bridge for the ai@7 telemetry surface.
140
- *
141
- * It wraps model calls and tool executions in Sentry spans (via
142
- * `Sentry.startSpan`) so nested provider/tool work is correctly parented, and
143
- * routes `onError` to `Sentry.captureException`. Span attributes carry only
144
- * structural metadata (model, provider, tool name) unless `recordInputs` is
145
- * set, in which case prompts / tool arguments are attached too.
146
- *
147
- * The app owns Sentry initialization; pass the namespace in as `Sentry`.
148
- */
293
+ * A dependency-injected Sentry bridge for the ai@7 telemetry surface.
294
+ *
295
+ * It wraps model calls and tool executions in Sentry spans so nested
296
+ * provider/tool work is correctly parented, and routes `onError` to
297
+ * `Sentry.captureException`. Span attributes carry only structural metadata
298
+ * (model, provider, tool name, token usage) unless `recordInputs` /
299
+ * `recordOutputs` are set, in which case prompts, tool arguments and generated
300
+ * text are attached too.
301
+ *
302
+ * The tool span is driven by the agent LOOP, not by `ai`: Lunora exposes tools
303
+ * schema-only so the SDK never executes one (see `telemetry/tool-execution.ts`).
304
+ *
305
+ * **A model-call span closes when the CALL ends, not when `execute()` resolves.**
306
+ * On a streamed turn `execute()` resolves the instant `doStream` hands back the
307
+ * stream — before a token, before any usage. The span still OPENS around
308
+ * `execute()`, because that is what makes it the active span nested provider work
309
+ * parents to, but it is opened with `startSpanManual` and so is not finished
310
+ * there: `onLanguageModelCallEnd` ends it, once the response is normalized and
311
+ * the real duration and token usage are both known. `onAbort` / `onError` end the
312
+ * call they name as a failure, so a stream that dies or is barged in on reports
313
+ * one instead of a phantom success.
314
+ *
315
+ * The app owns Sentry initialization; pass the namespace in as `Sentry`.
316
+ * @experimental
317
+ */
149
318
  declare const sentryTelemetry: (options: SentryTelemetryOptions) => Telemetry;
150
- export { type BraintrustLike, type BraintrustSpan, type BraintrustTelemetryOptions, type CommonOptions, type ConsoleLogLevel, type ConsoleLogger, type ConsoleTelemetryOptions, type SentryLike, type SentryTelemetryOptions, braintrustTelemetry, combineTelemetry, consoleTelemetry, sentryTelemetry };
319
+ export {
320
+ /**
321
+ * `@lunora/agent/telemetry` — observability integrations for `@lunora/agent`.
322
+ *
323
+ * Every export here produces an ai@7 `Telemetry` object suitable for the
324
+ * `integrations` array of `TelemetryOptions` (`defineAgent({ telemetry: {
325
+ * isEnabled: true, integrations: [...] } })`). `consoleTelemetry` is a
326
+ * zero-dependency structured console tracer; `combineTelemetry` fans the
327
+ * lifecycle out to several integrations and nests their execution wrappers;
328
+ * `sentryTelemetry` / `braintrustTelemetry` are dependency-injected bridges (the
329
+ * app passes its own Sentry namespace / Braintrust logger, so the heavy SDKs are
330
+ * never imported here); and `otlpTelemetry` ships `gen_ai.*` spans over
331
+ * OTLP-over-HTTP to any collector (the Lunora Cloud, or your own), so agent
332
+ * generations land in the same trace store as the rest of the app.
333
+ *
334
+ * All integrations are privacy-safe by default (`recordInputs` / `recordOutputs`
335
+ * both default `false`), so nothing sensitive is recorded without opt-in.
336
+ */
337
+ type BraintrustLike,
338
+ /**
339
+ * `@lunora/agent/telemetry` — observability integrations for `@lunora/agent`.
340
+ *
341
+ * Every export here produces an ai@7 `Telemetry` object suitable for the
342
+ * `integrations` array of `TelemetryOptions` (`defineAgent({ telemetry: {
343
+ * isEnabled: true, integrations: [...] } })`). `consoleTelemetry` is a
344
+ * zero-dependency structured console tracer; `combineTelemetry` fans the
345
+ * lifecycle out to several integrations and nests their execution wrappers;
346
+ * `sentryTelemetry` / `braintrustTelemetry` are dependency-injected bridges (the
347
+ * app passes its own Sentry namespace / Braintrust logger, so the heavy SDKs are
348
+ * never imported here); and `otlpTelemetry` ships `gen_ai.*` spans over
349
+ * OTLP-over-HTTP to any collector (the Lunora Cloud, or your own), so agent
350
+ * generations land in the same trace store as the rest of the app.
351
+ *
352
+ * All integrations are privacy-safe by default (`recordInputs` / `recordOutputs`
353
+ * both default `false`), so nothing sensitive is recorded without opt-in.
354
+ */
355
+ type BraintrustSpan,
356
+ /**
357
+ * `@lunora/agent/telemetry` — observability integrations for `@lunora/agent`.
358
+ *
359
+ * Every export here produces an ai@7 `Telemetry` object suitable for the
360
+ * `integrations` array of `TelemetryOptions` (`defineAgent({ telemetry: {
361
+ * isEnabled: true, integrations: [...] } })`). `consoleTelemetry` is a
362
+ * zero-dependency structured console tracer; `combineTelemetry` fans the
363
+ * lifecycle out to several integrations and nests their execution wrappers;
364
+ * `sentryTelemetry` / `braintrustTelemetry` are dependency-injected bridges (the
365
+ * app passes its own Sentry namespace / Braintrust logger, so the heavy SDKs are
366
+ * never imported here); and `otlpTelemetry` ships `gen_ai.*` spans over
367
+ * OTLP-over-HTTP to any collector (the Lunora Cloud, or your own), so agent
368
+ * generations land in the same trace store as the rest of the app.
369
+ *
370
+ * All integrations are privacy-safe by default (`recordInputs` / `recordOutputs`
371
+ * both default `false`), so nothing sensitive is recorded without opt-in.
372
+ */
373
+ type BraintrustTelemetryOptions, type CommonOptions, type ConsoleLogLevel, type ConsoleLogger, type ConsoleTelemetryOptions, type OtlpTelemetryOptions, type SentryLike, type SentrySpan, type SentryTelemetryOptions, braintrustTelemetry, combineTelemetry, consoleTelemetry, otlpTelemetry, sentryTelemetry };
@@ -1,4 +1 @@
1
- export { braintrustTelemetry } from '../packem_shared/braintrustTelemetry-wuGDErob.mjs';
2
- export { combineTelemetry } from '../packem_shared/combineTelemetry-DCyaaWAI.mjs';
3
- export { consoleTelemetry } from '../packem_shared/consoleTelemetry-z2MiP1jt.mjs';
4
- export { sentryTelemetry } from '../packem_shared/sentryTelemetry-CgqFJyLO.mjs';
1
+ import{braintrustTelemetry as o}from"../packem_shared/braintrustTelemetry-Byne8uPK.mjs";import{combineTelemetry as m}from"../packem_shared/combineTelemetry-DgE9W9G8.mjs";import{consoleTelemetry as p}from"../packem_shared/consoleTelemetry-BZY3Y-Ly.mjs";import{otlpTelemetry as f}from"../packem_shared/otlpTelemetry-ByqrB-72.mjs";import{sentryTelemetry as T}from"../packem_shared/sentryTelemetry-BHeydiAB.mjs";export{o as braintrustTelemetry,m as combineTelemetry,p as consoleTelemetry,f as otlpTelemetry,T as sentryTelemetry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/agent",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.100",
4
4
  "description": "Durable AI agents for Lunora: defineAgent compiles a replay-safe tool-loop onto Cloudflare Workflows, with DO SQLite threads and live message subscriptions",
5
5
  "keywords": [
6
6
  "agent",
@@ -62,6 +62,14 @@
62
62
  "types": "./dist/naming.d.ts",
63
63
  "import": "./dist/naming.mjs"
64
64
  },
65
+ "./skill-markdown": {
66
+ "types": "./dist/skill-markdown.d.ts",
67
+ "import": "./dist/skill-markdown.mjs"
68
+ },
69
+ "./reply": {
70
+ "types": "./dist/reply.d.ts",
71
+ "import": "./dist/reply.mjs"
72
+ },
65
73
  "./sandbox": {
66
74
  "types": "./dist/sandbox.d.ts",
67
75
  "import": "./dist/sandbox.mjs"
@@ -76,14 +84,15 @@
76
84
  "access": "public"
77
85
  },
78
86
  "dependencies": {
79
- "@lunora/ai": "1.0.0-alpha.14",
80
- "@lunora/errors": "1.0.0-alpha.4",
81
- "@lunora/mail": "1.0.0-alpha.14",
82
- "@lunora/server": "1.0.0-alpha.24",
83
- "@lunora/values": "1.0.0-alpha.7",
84
- "@lunora/workflow": "1.0.0-alpha.9",
85
- "@modelcontextprotocol/sdk": "^1.29.0",
86
- "ai": "7.0.16"
87
+ "@lunora/ai": "1.0.0-alpha.82",
88
+ "@lunora/errors": "1.0.0-alpha.35",
89
+ "@lunora/mail": "1.0.0-alpha.72",
90
+ "@lunora/server": "1.0.0-alpha.113",
91
+ "@lunora/values": "1.0.0-alpha.43",
92
+ "@lunora/workflow": "1.0.0-alpha.49",
93
+ "@modelcontextprotocol/sdk": "^1.30.0",
94
+ "ai": "7.0.93",
95
+ "yaml": "^2.9.0"
87
96
  },
88
97
  "engines": {
89
98
  "node": "^22.15.0 || >=24.11.0"
@@ -1,24 +0,0 @@
1
- const AGENT_MODULE = "agents";
2
- const SANDBOX_MODULE = "sandbox";
3
- const SANDBOX_INVOKE_PATH = `${SANDBOX_MODULE}:invoke`;
4
- const DEFAULT_AGENT_FUNCTION_PATHS = {
5
- appendMessage: `${AGENT_MODULE}:agentAppendMessage`,
6
- ensureThread: `${AGENT_MODULE}:agentEnsureThread`,
7
- episodeRecall: `${AGENT_MODULE}:agentEpisodeRecall`,
8
- episodeUpsert: `${AGENT_MODULE}:agentEpisodeUpsert`,
9
- graphTraverse: `${AGENT_MODULE}:agentGraphTraverse`,
10
- graphUpsert: `${AGENT_MODULE}:agentGraphUpsert`,
11
- listMessages: `${AGENT_MODULE}:agentMessages`,
12
- patchThread: `${AGENT_MODULE}:agentPatchThread`,
13
- run: `${AGENT_MODULE}:agentRun`,
14
- setState: `${AGENT_MODULE}:agentSetState`,
15
- state: `${AGENT_MODULE}:agentState`
16
- };
17
- const toFunctionReference = (source) => {
18
- if (typeof source === "string") {
19
- return { __lunoraRef: source };
20
- }
21
- return source;
22
- };
23
-
24
- export { AGENT_MODULE, DEFAULT_AGENT_FUNCTION_PATHS, SANDBOX_INVOKE_PATH, SANDBOX_MODULE, toFunctionReference };