@lunora/agent 1.0.0-alpha.1 → 1.0.0-alpha.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.
- package/README.md +2 -0
- package/dist/channels.d.mts +17 -5
- package/dist/channels.d.ts +17 -5
- package/dist/component.d.mts +14 -0
- package/dist/component.d.ts +14 -0
- package/dist/inbound.d.mts +7 -2
- package/dist/inbound.d.ts +7 -2
- package/dist/index.d.mts +136 -28
- package/dist/index.d.ts +136 -28
- package/dist/naming.d.mts +17 -4
- package/dist/naming.d.ts +17 -4
- package/dist/packem_shared/{types.d-BWG0uUtX.d.mts → types.d-BhJFTvz_.d.mts} +123 -24
- package/dist/packem_shared/{types.d-BWG0uUtX.d.ts → types.d-BhJFTvz_.d.ts} +123 -24
- package/dist/sandbox.d.mts +19 -4
- package/dist/sandbox.d.ts +19 -4
- package/dist/telemetry/index.d.mts +28 -5
- package/dist/telemetry/index.d.ts +28 -5
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @lunora/agent
|
|
2
2
|
|
|
3
|
+
> **Experimental** — this package is outside the Lunora 1.0 stability promise: its API may change in any release, without a major version bump.
|
|
4
|
+
|
|
3
5
|
Durable AI agents for [Lunora](https://lunora.sh): `defineAgent` compiles a replay-safe tool-loop onto Cloudflare Workflows — each LLM turn and each tool call is a named durable step, thread messages persist idempotently in DO SQLite, and clients watch the conversation live over Lunora's reactive subscriptions.
|
|
4
6
|
|
|
5
7
|
```ts
|
package/dist/channels.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { A as AgentDefinition } from "./packem_shared/types.d-
|
|
2
|
-
export type { I as InboundChannelEvent } from "./packem_shared/types.d-
|
|
1
|
+
import { A as AgentDefinition } from "./packem_shared/types.d-BhJFTvz_.mjs";
|
|
2
|
+
export type { I as InboundChannelEvent } from "./packem_shared/types.d-BhJFTvz_.mjs";
|
|
3
3
|
import '@lunora/mail/inbound';
|
|
4
4
|
import 'ai';
|
|
5
5
|
/**
|
|
6
6
|
* Verify a Slack request signature (`x-slack-signature` = `v0=` + HMAC over
|
|
7
7
|
* `v0:timestamp:body`), rejecting a stale timestamp to bound replay. `now` is
|
|
8
8
|
* injectable for deterministic tests (defaults to the wall clock).
|
|
9
|
+
* @experimental
|
|
9
10
|
*/
|
|
10
11
|
declare const verifySlack: (options: {
|
|
11
12
|
body: string;
|
|
@@ -15,7 +16,10 @@ declare const verifySlack: (options: {
|
|
|
15
16
|
timestamp: string | undefined;
|
|
16
17
|
tolerance?: number;
|
|
17
18
|
}) => Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Verify a GitHub webhook signature (`x-hub-signature-256` = `sha256=` + HMAC over the body).
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
19
23
|
declare const verifyGithub: (options: {
|
|
20
24
|
body: string;
|
|
21
25
|
secret: string;
|
|
@@ -24,6 +28,7 @@ declare const verifyGithub: (options: {
|
|
|
24
28
|
/**
|
|
25
29
|
* Verify a Discord interaction signature: Ed25519 over `timestamp + body`,
|
|
26
30
|
* `x-signature-ed25519` (hex) against the application's `publicKey` (hex).
|
|
31
|
+
* @experimental
|
|
27
32
|
*/
|
|
28
33
|
declare const verifyDiscord: (options: {
|
|
29
34
|
body: string;
|
|
@@ -31,14 +36,20 @@ declare const verifyDiscord: (options: {
|
|
|
31
36
|
signature: string | undefined;
|
|
32
37
|
timestamp: string | undefined;
|
|
33
38
|
}) => Promise<boolean>;
|
|
34
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* One agent wired into the inbound channel HTTP handler.
|
|
41
|
+
* @experimental
|
|
42
|
+
*/
|
|
35
43
|
interface AgentChannelTarget {
|
|
36
44
|
/** The agent definition — only its `onInbound` config is read. */
|
|
37
45
|
agent: Pick<AgentDefinition, "onInbound">;
|
|
38
46
|
/** The `AGENT_*` Workflow binding name (off `env`) that starts a run. */
|
|
39
47
|
binding: string;
|
|
40
48
|
}
|
|
41
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The HTTP handler `dispatchAgentChannel` returns — mount it on a webhook route.
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
42
53
|
type InboundChannelHandler = (request: Request, env: Record<string, unknown>) => Promise<Response>;
|
|
43
54
|
/**
|
|
44
55
|
* Build an HTTP handler that starts a durable agent run from a verified inbound
|
|
@@ -49,6 +60,7 @@ type InboundChannelHandler = (request: Request, env: Record<string, unknown>) =>
|
|
|
49
60
|
* binding. Returns `401` when NO target's signature verifies, `200` on a claim
|
|
50
61
|
* (or a Discord PONG), `204` when a verified event is declined by every mapper,
|
|
51
62
|
* and `400` for an unrecognized webhook.
|
|
63
|
+
* @experimental
|
|
52
64
|
*/
|
|
53
65
|
declare const dispatchAgentChannel: (targets: ReadonlyArray<AgentChannelTarget>) => InboundChannelHandler;
|
|
54
66
|
export { type AgentChannelTarget, type InboundChannelHandler, dispatchAgentChannel, verifyDiscord, verifyGithub, verifySlack };
|
package/dist/channels.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { A as AgentDefinition } from "./packem_shared/types.d-
|
|
2
|
-
export type { I as InboundChannelEvent } from "./packem_shared/types.d-
|
|
1
|
+
import { A as AgentDefinition } from "./packem_shared/types.d-BhJFTvz_.js";
|
|
2
|
+
export type { I as InboundChannelEvent } from "./packem_shared/types.d-BhJFTvz_.js";
|
|
3
3
|
import '@lunora/mail/inbound';
|
|
4
4
|
import 'ai';
|
|
5
5
|
/**
|
|
6
6
|
* Verify a Slack request signature (`x-slack-signature` = `v0=` + HMAC over
|
|
7
7
|
* `v0:timestamp:body`), rejecting a stale timestamp to bound replay. `now` is
|
|
8
8
|
* injectable for deterministic tests (defaults to the wall clock).
|
|
9
|
+
* @experimental
|
|
9
10
|
*/
|
|
10
11
|
declare const verifySlack: (options: {
|
|
11
12
|
body: string;
|
|
@@ -15,7 +16,10 @@ declare const verifySlack: (options: {
|
|
|
15
16
|
timestamp: string | undefined;
|
|
16
17
|
tolerance?: number;
|
|
17
18
|
}) => Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Verify a GitHub webhook signature (`x-hub-signature-256` = `sha256=` + HMAC over the body).
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
19
23
|
declare const verifyGithub: (options: {
|
|
20
24
|
body: string;
|
|
21
25
|
secret: string;
|
|
@@ -24,6 +28,7 @@ declare const verifyGithub: (options: {
|
|
|
24
28
|
/**
|
|
25
29
|
* Verify a Discord interaction signature: Ed25519 over `timestamp + body`,
|
|
26
30
|
* `x-signature-ed25519` (hex) against the application's `publicKey` (hex).
|
|
31
|
+
* @experimental
|
|
27
32
|
*/
|
|
28
33
|
declare const verifyDiscord: (options: {
|
|
29
34
|
body: string;
|
|
@@ -31,14 +36,20 @@ declare const verifyDiscord: (options: {
|
|
|
31
36
|
signature: string | undefined;
|
|
32
37
|
timestamp: string | undefined;
|
|
33
38
|
}) => Promise<boolean>;
|
|
34
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* One agent wired into the inbound channel HTTP handler.
|
|
41
|
+
* @experimental
|
|
42
|
+
*/
|
|
35
43
|
interface AgentChannelTarget {
|
|
36
44
|
/** The agent definition — only its `onInbound` config is read. */
|
|
37
45
|
agent: Pick<AgentDefinition, "onInbound">;
|
|
38
46
|
/** The `AGENT_*` Workflow binding name (off `env`) that starts a run. */
|
|
39
47
|
binding: string;
|
|
40
48
|
}
|
|
41
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The HTTP handler `dispatchAgentChannel` returns — mount it on a webhook route.
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
42
53
|
type InboundChannelHandler = (request: Request, env: Record<string, unknown>) => Promise<Response>;
|
|
43
54
|
/**
|
|
44
55
|
* Build an HTTP handler that starts a durable agent run from a verified inbound
|
|
@@ -49,6 +60,7 @@ type InboundChannelHandler = (request: Request, env: Record<string, unknown>) =>
|
|
|
49
60
|
* binding. Returns `401` when NO target's signature verifies, `200` on a claim
|
|
50
61
|
* (or a Discord PONG), `204` when a verified event is declined by every mapper,
|
|
51
62
|
* and `400` for an unrecognized webhook.
|
|
63
|
+
* @experimental
|
|
52
64
|
*/
|
|
53
65
|
declare const dispatchAgentChannel: (targets: ReadonlyArray<AgentChannelTarget>) => InboundChannelHandler;
|
|
54
66
|
export { type AgentChannelTarget, type InboundChannelHandler, dispatchAgentChannel, verifyDiscord, verifyGithub, verifySlack };
|
package/dist/component.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ interface AgentRegisteredFunction {
|
|
|
17
17
|
* The per-owner dedup key for an entity name: trim, collapse internal
|
|
18
18
|
* whitespace, lowercase. Deterministic (no locale) so a workflow replay or
|
|
19
19
|
* retry writes the exact same key — the graph upsert stays idempotent.
|
|
20
|
+
* @experimental
|
|
20
21
|
*/
|
|
21
22
|
declare const normalizeEntityName: (name: string) => string;
|
|
22
23
|
/** The two internal graph-memory functions the durable loop dispatches to. */
|
|
@@ -25,6 +26,7 @@ declare const normalizeEntityName: (name: string) => string;
|
|
|
25
26
|
* Loose structural view of the registered sandbox action — wide enough for the
|
|
26
27
|
* concrete `RegisteredAction`, narrow enough for re-export + dispatch. Codegen
|
|
27
28
|
* registers the runtime value; it never needs the precise generics.
|
|
29
|
+
* @experimental
|
|
28
30
|
*/
|
|
29
31
|
interface SandboxRegisteredFunction {
|
|
30
32
|
readonly args: unknown;
|
|
@@ -32,6 +34,10 @@ interface SandboxRegisteredFunction {
|
|
|
32
34
|
readonly kind: "action";
|
|
33
35
|
readonly visibility?: "internal" | "public";
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* `SandboxComponent` is part of the experimental `@lunora/agent` API and may change without a major version bump.
|
|
39
|
+
* @experimental
|
|
40
|
+
*/
|
|
35
41
|
interface SandboxComponent {
|
|
36
42
|
invoke: SandboxRegisteredFunction;
|
|
37
43
|
}
|
|
@@ -41,6 +47,7 @@ interface SandboxComponent {
|
|
|
41
47
|
* to start with the normalized `root`, so the model can never read or write
|
|
42
48
|
* outside its own prefix — the fs sandbox's core isolation guarantee.
|
|
43
49
|
*/
|
|
50
|
+
|
|
44
51
|
/**
|
|
45
52
|
* Build the sandbox runtime component: the single internal action the
|
|
46
53
|
* batteries-included `browserTool`/`containerTool` dispatch to. Codegen
|
|
@@ -48,6 +55,7 @@ interface SandboxComponent {
|
|
|
48
55
|
* tool. It runs as an **action** because that is the only ctx codegen attaches
|
|
49
56
|
* `ctx.browser` to (and `ctx.containers` rides every ctx once a container is
|
|
50
57
|
* declared) — the durable tool step itself has neither.
|
|
58
|
+
* @experimental
|
|
51
59
|
*/
|
|
52
60
|
declare const sandboxComponent: () => SandboxComponent;
|
|
53
61
|
/**
|
|
@@ -64,8 +72,13 @@ declare const sandboxComponent: () => SandboxComponent;
|
|
|
64
72
|
* allocation is O(1) inside the serialized mutation), and `messageKey` is the
|
|
65
73
|
* deterministic idempotency key — a workflow replay that re-persists the same
|
|
66
74
|
* message is a no-op instead of a duplicate.
|
|
75
|
+
* @experimental
|
|
67
76
|
*/
|
|
68
77
|
declare const agentExtension: SchemaExtension;
|
|
78
|
+
/**
|
|
79
|
+
* `AgentComponent` is part of the experimental `@lunora/agent` API and may change without a major version bump.
|
|
80
|
+
* @experimental
|
|
81
|
+
*/
|
|
69
82
|
interface AgentComponent {
|
|
70
83
|
extension: SchemaExtension;
|
|
71
84
|
functions: {
|
|
@@ -96,6 +109,7 @@ interface AgentComponent {
|
|
|
96
109
|
* to `agents:agentMessages` for a live thread view. Two mutations are public:
|
|
97
110
|
* `agentResolveApproval` (a client resolves a HITL approval) and `agentRun`
|
|
98
111
|
* (an HTTP client starts a durable run) — both owner-gated.
|
|
112
|
+
* @experimental
|
|
99
113
|
*/
|
|
100
114
|
declare const agentComponent: () => AgentComponent;
|
|
101
115
|
export { AgentComponent, type SandboxComponent, type SandboxRegisteredFunction, agentComponent, agentExtension, normalizeEntityName, sandboxComponent };
|
package/dist/component.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface AgentRegisteredFunction {
|
|
|
17
17
|
* The per-owner dedup key for an entity name: trim, collapse internal
|
|
18
18
|
* whitespace, lowercase. Deterministic (no locale) so a workflow replay or
|
|
19
19
|
* retry writes the exact same key — the graph upsert stays idempotent.
|
|
20
|
+
* @experimental
|
|
20
21
|
*/
|
|
21
22
|
declare const normalizeEntityName: (name: string) => string;
|
|
22
23
|
/** The two internal graph-memory functions the durable loop dispatches to. */
|
|
@@ -25,6 +26,7 @@ declare const normalizeEntityName: (name: string) => string;
|
|
|
25
26
|
* Loose structural view of the registered sandbox action — wide enough for the
|
|
26
27
|
* concrete `RegisteredAction`, narrow enough for re-export + dispatch. Codegen
|
|
27
28
|
* registers the runtime value; it never needs the precise generics.
|
|
29
|
+
* @experimental
|
|
28
30
|
*/
|
|
29
31
|
interface SandboxRegisteredFunction {
|
|
30
32
|
readonly args: unknown;
|
|
@@ -32,6 +34,10 @@ interface SandboxRegisteredFunction {
|
|
|
32
34
|
readonly kind: "action";
|
|
33
35
|
readonly visibility?: "internal" | "public";
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* `SandboxComponent` is part of the experimental `@lunora/agent` API and may change without a major version bump.
|
|
39
|
+
* @experimental
|
|
40
|
+
*/
|
|
35
41
|
interface SandboxComponent {
|
|
36
42
|
invoke: SandboxRegisteredFunction;
|
|
37
43
|
}
|
|
@@ -41,6 +47,7 @@ interface SandboxComponent {
|
|
|
41
47
|
* to start with the normalized `root`, so the model can never read or write
|
|
42
48
|
* outside its own prefix — the fs sandbox's core isolation guarantee.
|
|
43
49
|
*/
|
|
50
|
+
|
|
44
51
|
/**
|
|
45
52
|
* Build the sandbox runtime component: the single internal action the
|
|
46
53
|
* batteries-included `browserTool`/`containerTool` dispatch to. Codegen
|
|
@@ -48,6 +55,7 @@ interface SandboxComponent {
|
|
|
48
55
|
* tool. It runs as an **action** because that is the only ctx codegen attaches
|
|
49
56
|
* `ctx.browser` to (and `ctx.containers` rides every ctx once a container is
|
|
50
57
|
* declared) — the durable tool step itself has neither.
|
|
58
|
+
* @experimental
|
|
51
59
|
*/
|
|
52
60
|
declare const sandboxComponent: () => SandboxComponent;
|
|
53
61
|
/**
|
|
@@ -64,8 +72,13 @@ declare const sandboxComponent: () => SandboxComponent;
|
|
|
64
72
|
* allocation is O(1) inside the serialized mutation), and `messageKey` is the
|
|
65
73
|
* deterministic idempotency key — a workflow replay that re-persists the same
|
|
66
74
|
* message is a no-op instead of a duplicate.
|
|
75
|
+
* @experimental
|
|
67
76
|
*/
|
|
68
77
|
declare const agentExtension: SchemaExtension;
|
|
78
|
+
/**
|
|
79
|
+
* `AgentComponent` is part of the experimental `@lunora/agent` API and may change without a major version bump.
|
|
80
|
+
* @experimental
|
|
81
|
+
*/
|
|
69
82
|
interface AgentComponent {
|
|
70
83
|
extension: SchemaExtension;
|
|
71
84
|
functions: {
|
|
@@ -96,6 +109,7 @@ interface AgentComponent {
|
|
|
96
109
|
* to `agents:agentMessages` for a live thread view. Two mutations are public:
|
|
97
110
|
* `agentResolveApproval` (a client resolves a HITL approval) and `agentRun`
|
|
98
111
|
* (an HTTP client starts a durable run) — both owner-gated.
|
|
112
|
+
* @experimental
|
|
99
113
|
*/
|
|
100
114
|
declare const agentComponent: () => AgentComponent;
|
|
101
115
|
export { AgentComponent, type SandboxComponent, type SandboxRegisteredFunction, agentComponent, agentExtension, normalizeEntityName, sandboxComponent };
|
package/dist/inbound.d.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { A as AgentDefinition } from "./packem_shared/types.d-
|
|
1
|
+
import { A as AgentDefinition } from "./packem_shared/types.d-BhJFTvz_.mjs";
|
|
2
2
|
import '@lunora/mail/inbound';
|
|
3
3
|
import 'ai';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* One agent wired into the inbound `email()` handler.
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
5
8
|
interface AgentEmailTarget {
|
|
6
9
|
/**
|
|
7
10
|
* The agent definition — only its `onEmail` mapper is read, deciding whether
|
|
@@ -15,6 +18,7 @@ interface AgentEmailTarget {
|
|
|
15
18
|
* The worker `email(message, env, ctx)` callback. Typed with `unknown`
|
|
16
19
|
* parameters so it drops straight onto the generated `composed.email` slot
|
|
17
20
|
* without a cast.
|
|
21
|
+
* @experimental
|
|
18
22
|
*/
|
|
19
23
|
type InboundAgentEmailHandler = (message: unknown, env: unknown, context: unknown) => Promise<void>;
|
|
20
24
|
/**
|
|
@@ -24,6 +28,7 @@ type InboundAgentEmailHandler = (message: unknown, env: unknown, context: unknow
|
|
|
24
28
|
* matched agent's Workflow binding is missing from `env` (run codegen/dev so
|
|
25
29
|
* `wrangler.jsonc` declares it) the dispatch throws, and the inbound handler's
|
|
26
30
|
* `onError` rejects (bounces) the message.
|
|
31
|
+
* @experimental
|
|
27
32
|
*/
|
|
28
33
|
declare const dispatchAgentEmail: (targets: ReadonlyArray<AgentEmailTarget>) => InboundAgentEmailHandler;
|
|
29
34
|
export { type AgentEmailTarget, type InboundAgentEmailHandler, dispatchAgentEmail };
|
package/dist/inbound.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { A as AgentDefinition } from "./packem_shared/types.d-
|
|
1
|
+
import { A as AgentDefinition } from "./packem_shared/types.d-BhJFTvz_.js";
|
|
2
2
|
import '@lunora/mail/inbound';
|
|
3
3
|
import 'ai';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* One agent wired into the inbound `email()` handler.
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
5
8
|
interface AgentEmailTarget {
|
|
6
9
|
/**
|
|
7
10
|
* The agent definition — only its `onEmail` mapper is read, deciding whether
|
|
@@ -15,6 +18,7 @@ interface AgentEmailTarget {
|
|
|
15
18
|
* The worker `email(message, env, ctx)` callback. Typed with `unknown`
|
|
16
19
|
* parameters so it drops straight onto the generated `composed.email` slot
|
|
17
20
|
* without a cast.
|
|
21
|
+
* @experimental
|
|
18
22
|
*/
|
|
19
23
|
type InboundAgentEmailHandler = (message: unknown, env: unknown, context: unknown) => Promise<void>;
|
|
20
24
|
/**
|
|
@@ -24,6 +28,7 @@ type InboundAgentEmailHandler = (message: unknown, env: unknown, context: unknow
|
|
|
24
28
|
* matched agent's Workflow binding is missing from `env` (run codegen/dev so
|
|
25
29
|
* `wrangler.jsonc` declares it) the dispatch throws, and the inbound handler's
|
|
26
30
|
* `onError` rejects (bounces) the message.
|
|
31
|
+
* @experimental
|
|
27
32
|
*/
|
|
28
33
|
declare const dispatchAgentEmail: (targets: ReadonlyArray<AgentEmailTarget>) => InboundAgentEmailHandler;
|
|
29
34
|
export { type AgentEmailTarget, type InboundAgentEmailHandler, dispatchAgentEmail };
|