@niscorp/cortex 0.1.5 → 0.1.6
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/CHANGELOG.md +11 -0
- package/DESIGN.md +25 -19
- package/README.md +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @niscorp/cortex
|
|
2
2
|
|
|
3
|
+
## 0.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 41ac0c7: DESIGN.md and the README say what the code does: the loop streams unless `transport: 'step'`, no event carries per-step usage, the schema check is conversion, no `$ref` and at most 8,192 characters (native also needs `nativeJsonSchema` and is sent with `strict: false`), `onRun` is an option of `createManifold`, and `agent.run` takes `agentPath`.
|
|
8
|
+
|
|
9
|
+
**What to change:** nothing. Documentation only.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [a2d2df0]
|
|
12
|
+
- @niscorp/solid@0.1.3
|
|
13
|
+
|
|
3
14
|
## 0.1.5
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/DESIGN.md
CHANGED
|
@@ -88,7 +88,7 @@ type RunResult<TData> =
|
|
|
88
88
|
| { ok: false; error: CortexError; meta: RunMeta };
|
|
89
89
|
|
|
90
90
|
type RunMeta = {
|
|
91
|
-
usage: Usage; //
|
|
91
|
+
usage: Usage; // the run's total; no event carries per-step usage
|
|
92
92
|
strategy: OutputStrategy; // what actually ran
|
|
93
93
|
steps: number;
|
|
94
94
|
outputRetries: number;
|
|
@@ -134,9 +134,9 @@ at most syntax; cortex enforces the contract.
|
|
|
134
134
|
|
|
135
135
|
Cortex registers one synthetic tool per run:
|
|
136
136
|
|
|
137
|
-
- **Params, auto-detailed.** If the
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
- **Params, auto-detailed.** If the envelope schema with `data`
|
|
138
|
+
converts to JSON Schema, contains no `$ref` and serializes to at
|
|
139
|
+
most 8,192 characters, it is inlined into the tool params.
|
|
140
140
|
Otherwise params are loose (`data: object, see OUTPUT SCHEMA in the
|
|
141
141
|
system prompt`) and the schema documentation is injected into
|
|
142
142
|
context (§3.4). This is what makes Prism's `NodeSchema` and Nova's
|
|
@@ -196,11 +196,13 @@ Cortex registers one synthetic tool per run:
|
|
|
196
196
|
|
|
197
197
|
### 3.2 `native`
|
|
198
198
|
|
|
199
|
-
`auto` picks it only when the
|
|
200
|
-
`
|
|
201
|
-
the envelope schema passes the
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
`auto` picks it only when the agent has an output schema, the model
|
|
200
|
+
capability `nativeJsonSchema` is true, `toolsWithStructuredOutput` is
|
|
201
|
+
true (or the agent has no tools) AND the envelope schema passes the
|
|
202
|
+
same check as `respond`'s inlined params (converts, no `$ref`, ≤ 8,192
|
|
203
|
+
characters). The schema is sent as `response_format` with
|
|
204
|
+
`strict: false`. Small extractors and classifiers on OpenAI-class
|
|
205
|
+
providers land here.
|
|
204
206
|
|
|
205
207
|
### 3.3 `emit`
|
|
206
208
|
|
|
@@ -281,9 +283,10 @@ Rules the loop lives by:
|
|
|
281
283
|
collision-free per run, and nothing may claim `respond`. (v1 sent
|
|
282
284
|
ids on the wire while documenting names — a prompt-literal model
|
|
283
285
|
exposed the lie.)
|
|
284
|
-
- **Streaming is
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
- **Streaming is the default.** The loop consumes `signal.stepStream`
|
|
287
|
+
unless the agent sets `transport: 'step'`, which calls `llm.step()`
|
|
288
|
+
and emits no deltas or partials (§11); `await run.result` is the
|
|
289
|
+
consumer's opt-out.
|
|
287
290
|
|
|
288
291
|
Bounds are `stopWhen` predicates — one vocabulary instead of v1's
|
|
289
292
|
maxToolIterations / maxTicks / maxDurationMs / budget tangle:
|
|
@@ -445,8 +448,9 @@ type StopCondition = (s: RunProgress) => StopVerdict; // { stop: StopReason; m
|
|
|
445
448
|
hand-rolled verify-once harness bolt-on.)
|
|
446
449
|
|
|
447
450
|
What hooks deliberately can't do: react to *other* runs (cross-run
|
|
448
|
-
choreography is app code
|
|
449
|
-
transcript (append-only is
|
|
451
|
+
choreography is app code in the `onRun` option of
|
|
452
|
+
`createManifold`), mutate past transcript (append-only is
|
|
453
|
+
load-bearing), veto text mid-generation
|
|
450
454
|
(validation happens at boundaries: tool call, step end, output). If
|
|
451
455
|
remotely-configured steering is ever needed, it lands as a compiler
|
|
452
456
|
from a config shape *to* a gate function — on top, not underneath.
|
|
@@ -479,8 +483,9 @@ const result = await run.result;
|
|
|
479
483
|
Every event carries `{ runId, agentPath, seq, ts }`. When an agent
|
|
480
484
|
runs inside another (`asTool`), the child's events forward into the
|
|
481
485
|
parent stream with the extended `agentPath` — one subscription sees
|
|
482
|
-
the whole tree.
|
|
483
|
-
|
|
486
|
+
the whole tree. No event carries usage: the run's total is
|
|
487
|
+
`RunMeta.usage`, which `run-end` carries in its `meta`; that is the
|
|
488
|
+
whole ledger.
|
|
484
489
|
|
|
485
490
|
Process-level watching is the manifold's tap: `onRun(run => …)` hands
|
|
486
491
|
you every run created through it. That is the one legitimate job the
|
|
@@ -553,7 +558,8 @@ principle as every other tool denial.
|
|
|
553
558
|
|
|
554
559
|
## 10. Streaming
|
|
555
560
|
|
|
556
|
-
|
|
561
|
+
On unless the agent sets `transport: 'step'` (§4). Solid is a
|
|
562
|
+
dependency and powers
|
|
557
563
|
`output-partial`: `respond` arg deltas (or content deltas under
|
|
558
564
|
`native`/`emit`) stream through solid's partial parser into
|
|
559
565
|
progressively-typed envelopes — a chat `response` string streams
|
|
@@ -572,7 +578,7 @@ defineTool(config): ToolDefinition // v1 shape, kept
|
|
|
572
578
|
schemaDoc(schema, opts?): string
|
|
573
579
|
|
|
574
580
|
// execution
|
|
575
|
-
agent.run(input, { deps, llm?, tools?, producers?, gates?, onToolResult?, onEvent?, signal? }): RunHandle<TData>
|
|
581
|
+
agent.run(input, { deps, llm?, tools?, producers?, gates?, onToolResult?, onEvent?, signal?, agentPath? }): RunHandle<TData>
|
|
576
582
|
// tools: per-run tools whose execute closes over per-invocation
|
|
577
583
|
// dependencies (vex builds its query tools around the caller's
|
|
578
584
|
// adapter + schema); appended to the agent's static tools.
|
|
@@ -715,7 +721,7 @@ src/
|
|
|
715
721
|
├── loop/
|
|
716
722
|
│ ├── loop.ts # the loop (§4) — all three transports
|
|
717
723
|
│ └── partials.ts # solid partial-output tracking
|
|
718
|
-
│ # (auto resolution, the
|
|
724
|
+
│ # (auto resolution, the schema size/`$ref` check, the respond
|
|
719
725
|
│ # descriptor and corrections are signal's: src/transport/)
|
|
720
726
|
│
|
|
721
727
|
├── context/
|
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ How the envelope travels from model to runtime. One field,
|
|
|
86
86
|
|
|
87
87
|
| Strategy | Mechanism | Fits |
|
|
88
88
|
|---|---|---|
|
|
89
|
-
| `native` | provider `response_format: json_schema`, in-loop |
|
|
89
|
+
| `native` | provider `response_format: json_schema`, in-loop | an output schema whose envelope converts to JSON Schema with no `$ref` in ≤ 8,192 characters, on a model with `nativeJsonSchema` (auto-picked; sent with `strict: false`) |
|
|
90
90
|
| `respond` | a synthesized `respond` tool; the envelope is its arguments | where the tool params can ENFORCE the contract — the endpoint does not validate tool args itself, the schema is small, the model carries nested args intact (auto-picked there) |
|
|
91
91
|
| `emit` | the model's completion IS the envelope (content channel) | everything else — auto-picked wherever neither of the above enforces anything: all of Groq, big schemas, models that mangle nested tool args |
|
|
92
92
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niscorp/cortex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Agent runtime — one tool loop, typed envelopes, gates, streamed events",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"node": ">=22.12"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@niscorp/solid": "0.1.
|
|
38
|
+
"@niscorp/solid": "0.1.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"zod": "^4.2.0",
|
|
42
|
-
"@niscorp/signal": "^0.1.
|
|
42
|
+
"@niscorp/signal": "^0.1.9"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.10.2",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"tsx": "^4.19.2",
|
|
48
48
|
"vitest": "^4.1.2",
|
|
49
49
|
"zod": "^4.6.5",
|
|
50
|
-
"@niscorp/signal": "0.1.
|
|
50
|
+
"@niscorp/signal": "0.1.9"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsup",
|