@lunora/agent 0.0.0 → 1.0.0-alpha.1

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 (52) hide show
  1. package/LICENSE.md +105 -0
  2. package/README.md +48 -43
  3. package/dist/channels.d.mts +54 -0
  4. package/dist/channels.d.ts +54 -0
  5. package/dist/channels.mjs +181 -0
  6. package/dist/component.d.mts +101 -0
  7. package/dist/component.d.ts +101 -0
  8. package/dist/component.mjs +407 -0
  9. package/dist/inbound.d.mts +29 -0
  10. package/dist/inbound.d.ts +29 -0
  11. package/dist/inbound.mjs +32 -0
  12. package/dist/index.d.mts +740 -0
  13. package/dist/index.d.ts +740 -0
  14. package/dist/index.mjs +18 -0
  15. package/dist/naming.d.mts +17 -0
  16. package/dist/naming.d.ts +17 -0
  17. package/dist/naming.mjs +8 -0
  18. package/dist/packem_shared/AGENT_MODULE-Dnt_-AAT.mjs +24 -0
  19. package/dist/packem_shared/VoiceSessionDO-DLoXsHGF.mjs +297 -0
  20. package/dist/packem_shared/adaptMcpResult-wtNMvLoP.mjs +65 -0
  21. package/dist/packem_shared/agentAsTool-Dt8NlU6k.mjs +94 -0
  22. package/dist/packem_shared/base64-BVwtgRJV.mjs +18 -0
  23. package/dist/packem_shared/braintrustTelemetry-wuGDErob.mjs +47 -0
  24. package/dist/packem_shared/buildModelMessages-BWFigaoo.mjs +69 -0
  25. package/dist/packem_shared/codeTool-CjgJOC9t.mjs +122 -0
  26. package/dist/packem_shared/collectAgenticMemoryTools-QrzpV-WX.mjs +97 -0
  27. package/dist/packem_shared/combineTelemetry-DCyaaWAI.mjs +43 -0
  28. package/dist/packem_shared/common-DAeFCot5.mjs +61 -0
  29. package/dist/packem_shared/compileAgentWorkflow-BxJjHgtD.mjs +55 -0
  30. package/dist/packem_shared/consoleTelemetry-z2MiP1jt.mjs +93 -0
  31. package/dist/packem_shared/createAgentContext-4xJGXNR4.mjs +50 -0
  32. package/dist/packem_shared/createAgentGenerate-BQv9YJ01.mjs +192 -0
  33. package/dist/packem_shared/createDispatchRunner-DSbp_dph-ZHTtxy3f.mjs +69 -0
  34. package/dist/packem_shared/defineAgent-D6maSbVc.mjs +148 -0
  35. package/dist/packem_shared/defineSkill-Ctf_S-rz.mjs +22 -0
  36. package/dist/packem_shared/functionTool-D6lCa2jB.mjs +20 -0
  37. package/dist/packem_shared/graph-component-aoUwO-f0.mjs +216 -0
  38. package/dist/packem_shared/memory-D4FPcBsX.mjs +12 -0
  39. package/dist/packem_shared/normalizeEntityName-CyEEWFkR.mjs +3 -0
  40. package/dist/packem_shared/runAgentLoop-Dhg4ZNvw.mjs +493 -0
  41. package/dist/packem_shared/runVoiceTurn-LnqLvCRR.mjs +211 -0
  42. package/dist/packem_shared/sandboxComponent-DR3pTwBL.mjs +194 -0
  43. package/dist/packem_shared/sentryTelemetry-CgqFJyLO.mjs +36 -0
  44. package/dist/packem_shared/types.d-BWG0uUtX.d.mts +1015 -0
  45. package/dist/packem_shared/types.d-BWG0uUtX.d.ts +1015 -0
  46. package/dist/sandbox.d.mts +185 -0
  47. package/dist/sandbox.d.ts +185 -0
  48. package/dist/sandbox.mjs +109 -0
  49. package/dist/telemetry/index.d.mts +150 -0
  50. package/dist/telemetry/index.d.ts +150 -0
  51. package/dist/telemetry/index.mjs +4 -0
  52. package/package.json +88 -7
@@ -0,0 +1,150 @@
1
+ import { Telemetry } from 'ai';
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
+ */
11
+ interface CommonOptions {
12
+ /**
13
+ * When `true`, record model/tool **input** — prompts, messages, and tool
14
+ * call arguments. Default `false`.
15
+ */
16
+ recordInputs?: boolean;
17
+ /**
18
+ * When `true`, record model/tool **output** — generated text and tool
19
+ * results. Default `false`.
20
+ */
21
+ recordOutputs?: boolean;
22
+ }
23
+ /** The span handle a {@link BraintrustLike.traced} callback receives. */
24
+ interface BraintrustSpan {
25
+ /** Attach structured fields to the current span. */
26
+ log: (event: Record<string, unknown>) => void;
27
+ }
28
+ /**
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
+ */
34
+ interface BraintrustLike {
35
+ /** Run `callback` inside a new traced span and return its result. */
36
+ traced: <T>(callback: (span: BraintrustSpan) => T, args?: {
37
+ name?: string;
38
+ type?: string;
39
+ }) => T;
40
+ }
41
+ /** Options for {@link braintrustTelemetry}. */
42
+ interface BraintrustTelemetryOptions extends CommonOptions {
43
+ /** Span-name prefix for the language-model call (e.g. the agent name). */
44
+ functionId?: string;
45
+ /**
46
+ * The caller's initialized Braintrust logger (dependency-injected). Import
47
+ * and initialize `braintrust` in your app and pass it as `logger`.
48
+ */
49
+ logger: BraintrustLike;
50
+ }
51
+ /**
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
+ */
61
+ declare const braintrustTelemetry: (options: BraintrustTelemetryOptions) => Telemetry;
62
+ /**
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
+ */
73
+ declare const combineTelemetry: (...integrations: Telemetry[]) => Telemetry;
74
+ /** Severity level passed to a {@link ConsoleLogger}. */
75
+ type ConsoleLogLevel = "error" | "info" | "warn";
76
+ /**
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
+ */
81
+ type ConsoleLogger = (level: ConsoleLogLevel, message: string, fields: Record<string, unknown>) => void;
82
+ /** Options for {@link consoleTelemetry}. */
83
+ interface ConsoleTelemetryOptions extends CommonOptions {
84
+ /**
85
+ * Identifier prefixed into every log message (e.g. the agent name). Helps
86
+ * correlate lines when several agents share one process. Optional.
87
+ */
88
+ functionId?: string;
89
+ /**
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
+ */
93
+ logger?: ConsoleLogger;
94
+ }
95
+ /**
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
+ */
106
+ declare const consoleTelemetry: (options?: ConsoleTelemetryOptions) => Telemetry;
107
+ /**
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
+ */
114
+ interface SentryLike {
115
+ /** Capture a thrown value / exception. */
116
+ 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;
127
+ }
128
+ /** Options for {@link sentryTelemetry}. */
129
+ interface SentryTelemetryOptions extends CommonOptions {
130
+ /** Span-name prefix for the language-model call (e.g. the agent name). */
131
+ functionId?: string;
132
+ /**
133
+ * The caller's already-initialized Sentry namespace (dependency-injected).
134
+ * `import * as Sentry from "@sentry/cloudflare"` and pass it as `Sentry`.
135
+ */
136
+ Sentry: SentryLike;
137
+ }
138
+ /**
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
+ */
149
+ 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 };
@@ -0,0 +1,4 @@
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';
package/package.json CHANGED
@@ -1,10 +1,91 @@
1
1
  {
2
2
  "name": "@lunora/agent",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for @lunora/agent",
3
+ "version": "1.0.0-alpha.1",
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
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
6
+ "agent",
7
+ "ai",
8
+ "ai-sdk",
9
+ "braintrust",
10
+ "cloudflare",
11
+ "durable-objects",
12
+ "llm",
13
+ "lunora",
14
+ "observability",
15
+ "sentry",
16
+ "telemetry",
17
+ "tool-use",
18
+ "tracing",
19
+ "workers",
20
+ "workflows"
21
+ ],
22
+ "homepage": "https://lunora.sh",
23
+ "bugs": "https://github.com/anolilab/lunora/issues",
24
+ "license": "FSL-1.1-Apache-2.0",
25
+ "author": {
26
+ "name": "Daniel Bannert",
27
+ "email": "d.bannert@anolilab.de"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/anolilab/lunora.git",
32
+ "directory": "packages/agent"
33
+ },
34
+ "files": [
35
+ "./dist",
36
+ "README.md",
37
+ "LICENSE.md"
38
+ ],
39
+ "type": "module",
40
+ "sideEffects": false,
41
+ "main": "./dist/index.mjs",
42
+ "module": "./dist/index.mjs",
43
+ "types": "./dist/index.d.ts",
44
+ "exports": {
45
+ ".": {
46
+ "types": "./dist/index.d.ts",
47
+ "import": "./dist/index.mjs"
48
+ },
49
+ "./channels": {
50
+ "types": "./dist/channels.d.ts",
51
+ "import": "./dist/channels.mjs"
52
+ },
53
+ "./component": {
54
+ "types": "./dist/component.d.ts",
55
+ "import": "./dist/component.mjs"
56
+ },
57
+ "./inbound": {
58
+ "types": "./dist/inbound.d.ts",
59
+ "import": "./dist/inbound.mjs"
60
+ },
61
+ "./naming": {
62
+ "types": "./dist/naming.d.ts",
63
+ "import": "./dist/naming.mjs"
64
+ },
65
+ "./sandbox": {
66
+ "types": "./dist/sandbox.d.ts",
67
+ "import": "./dist/sandbox.mjs"
68
+ },
69
+ "./telemetry": {
70
+ "types": "./dist/telemetry/index.d.ts",
71
+ "import": "./dist/telemetry/index.mjs"
72
+ },
73
+ "./package.json": "./package.json"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public"
77
+ },
78
+ "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
+ },
88
+ "engines": {
89
+ "node": "^22.15.0 || >=24.11.0"
90
+ }
91
+ }