@nightowlsdev/engine-ai-sdk 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Night Owls contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @nightowlsdev/engine-ai-sdk
2
+
3
+ > The AI-SDK-native engine, in the `engine-*` family — **v1 shipped**: a governed `ai@^6` `streamText` loop,
4
+ > sibling to `@nightowlsdev/engine-mastra`'s Mastra-backed facade.
5
+
6
+ Per the pluggable-engine architecture (`docs/strategy/2026-07-03-pluggable-engine-architecture.md` §2b), this
7
+ package hosts a from-scratch swarm loop built directly on the Vercel AI SDK (`streamText`) rather than Mastra.
8
+ It reuses the SAME governance plane as `engine-mastra` verbatim — `HookDispatcher`/`ToolApprovalPolicy`,
9
+ `CostGovernor`/pricing, tier routing, secrets, telemetry — and passes both `verifyEngineContract` (the shared
10
+ conformance suite) and a golden-trajectory parity gate against `engine-mastra`. v1 is **single-agent**: no
11
+ delegation, no workflows, no semantic recall (see "What v1 doesn't do" below).
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ pnpm add @nightowlsdev/engine-ai-sdk ai
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { defineSwarm } from "@nightowlsdev/core";
23
+ import { aiSdkEngine } from "@nightowlsdev/engine-ai-sdk";
24
+
25
+ export default defineSwarm({
26
+ // ...
27
+ engine: aiSdkEngine(),
28
+ });
29
+ ```
30
+
31
+ ## Capability matrix (vs. `engine-mastra`)
32
+
33
+ | Capability | `engine-mastra` (default) | `engine-ai-sdk` (v1) |
34
+ |---|---|---|
35
+ | Delegation / multi-agent | ✅ agents-as-tools, depth+cycle guards, budgets | ❌ `delegation: false` (single-agent v1; `ask_slug` delegation planned v1.1) |
36
+ | Workflows (strict/advisory) | ✅ `StepDriver` | ❌ `workflows: false` |
37
+ | Semantic recall / working memory | ✅ Mastra Memory + pgvector | ❌ `memory.semanticRecall`/`workingMemory`/`observational: false` — `memory.history: true` only |
38
+ | Tool approvals | ✅ SP5 waitpoint suspend | ✅ **native** `ai@6` per-tool `needsApproval` + engine-side `executeToolWithGate` fail-closed backstop |
39
+ | HITL ask / client tools | ✅ | ✅ (same `ask`/client-action contract) |
40
+ | Durable cross-process resume | ✅ (via Mastra store) | ◐ `hitl.durableResume` — **`false` by default**, opt-in via `aiSdkEngine({ durable: true })` (see below) |
41
+ | Events | ✅ tier 3, 12/12 `SwarmEvent` types | ✅ tier 3, **11 of 12** — `swarm.handoff` absent (`delegation: false`) |
42
+ | History source | Mastra Memory / message store | **Events-derived**: `history()`/reads are built from the persisted event log, not a separate message store |
43
+ | Cost governance, secrets, telemetry, scratchpad, cancellation (mid-stream) | ✅ | ✅ (same code, reused verbatim from core) |
44
+ | Rules (advise/enforce) | ✅ | ✅ |
45
+
46
+ The static descriptor is exported as `AI_SDK_ENGINE_CAPABILITIES` (`docs/spec/ENGINE-CONTRACT.md` §2c shape).
47
+
48
+ ### Tier-3-without-handoff note
49
+
50
+ `AI_SDK_ENGINE_CAPABILITIES.events.tier` is declared `3` (the metering tier), but `events.emits` deliberately
51
+ **excludes `swarm.handoff`** — handoff is a delegation-only event, and this engine's `delegation` is `false`.
52
+ **`emits` is authoritative over the declared tier** for which events actually stream: consumers (react's
53
+ `useEngineCapabilities()`, the runner boot guards) should check `emits.includes(type)`, not infer event
54
+ support purely from the tier number.
55
+
56
+ ### The `durable` flag
57
+
58
+ ```ts
59
+ aiSdkEngine({ durable?: boolean }) // default: false
60
+ ```
61
+
62
+ `durableResume` is a per-**instance** capability flip, never inferred from the injected `StorageAdapter` —
63
+ mirroring `engine-mastra`'s own construction contract. Pass `aiSdkEngine({ durable: true })` **only** when
64
+ your `StorageAdapter` persists suspend/resume snapshots **across processes** (e.g.
65
+ `@nightowlsdev/storage-supabase`). Leave the default `false` for any storage that doesn't (in-memory / dev,
66
+ or a `StorageAdapter` you haven't verified), so `@nightowlsdev/runner-background` and `@nightowlsdev/mcp-server`
67
+ keep treating `ask`/approval resumes as **non-durable** and advise/warn accordingly instead of silently
68
+ promising a resume that can't survive a process restart.
69
+
70
+ ## What v1 doesn't do (honesty list)
71
+
72
+ - **No delegation** — `delegation: false`. Multi-agent packs (agent-kit's crews, Growth Strategist, Design
73
+ Studio) require `engine-mastra` until `ask_slug`-based delegation ships in **v1.1**.
74
+ - **No workflows** — `workflows: false`. Strict/advisory `defineWorkflow` procedures are not (yet) ported;
75
+ use `engine-mastra` for workflow-driven swarms.
76
+ - **No semantic recall** — `memory.semanticRecall`, `memory.workingMemory`, and `memory.observational` are
77
+ all `false`. Only `memory.history` (event-log-derived message history) is supported.
78
+ - **`governance.preToolCall` cap-ask `'ask'` deferred** — the cap-hit `ask` escalation path is deferred; see
79
+ the engine source for the current cap-hit behavior.
80
+ - **`ask`/client-resume emits no `swarm.tool_result`** — a documented wire asymmetry vs. `engine-mastra`: on
81
+ resume, the built-in `ask` tool is execute-less on this engine, so there is no tool-result to report for
82
+ the answered call (verified as a legitimate divergence by the cross-engine parity suite, not a bug).
83
+
84
+ ## API
85
+
86
+ ### `aiSdkEngine(opts?)`
87
+
88
+ ```ts
89
+ function aiSdkEngine(opts?: { durable?: boolean }): (opts: AssembledEngineOpts) => Engine
90
+ ```
91
+
92
+ Returns an engine factory for `defineSwarm({ engine })`. Constructs a governed `ai@^6` `streamText` loop
93
+ (`AiSdkEngine`) from the fully-assembled `AssembledEngineOpts` `defineSwarm` hands it — the same construction
94
+ contract `engine-mastra`'s `mastraEngine()` follows.
95
+
96
+ ### `AiSdkEngine`
97
+
98
+ The concrete `Engine` implementation. Re-exported from the package barrel for direct construction/typing.
99
+
100
+ ### `AI_SDK_ENGINE_CAPABILITIES`
101
+
102
+ The engine's static `EngineCapabilities` descriptor (`docs/spec/ENGINE-CONTRACT.md`). `id: "ai-sdk"`, tier-3
103
+ events (`swarm.handoff` absent — see the note above), full HITL except durable resume by default, no
104
+ delegation, no workflows, mid-stream cancellation, full governance (`preGeneration`, fail-closed
105
+ `preToolCall`, cost caps, secrets), telemetry on.
106
+
107
+ ### `nightOwlsPlugin`
108
+
109
+ The declarative plugin manifest consumed by `@nightowlsdev/cli` (`kind: "engine"`). Data-only — it does not
110
+ import from `@nightowlsdev/cli` (no dependency cycle).
111
+
112
+ ## See also
113
+
114
+ - [`docs/spec/ENGINE-CONTRACT.md`](../../docs/spec/ENGINE-CONTRACT.md) — the normative structural `Engine`
115
+ interface + behavioral invariants every engine (this one included) must satisfy.
116
+ - [`docs/strategy/2026-07-03-pluggable-engine-architecture.md`](../../docs/strategy/2026-07-03-pluggable-engine-architecture.md)
117
+ §2b — the engine family, the value proposition for a second native engine, and the v1.1+ roadmap.
118
+ - `@nightowlsdev/engine-mastra` — the sibling default (Mastra-backed) engine package; the multi-agent /
119
+ workflow / semantic-recall path today.