@zelari/core 2.0.0-alpha.3 → 2.0.0-alpha.5
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/dist/session/agentAdapter.d.ts +31 -0
- package/dist/session/agentAdapter.d.ts.map +1 -0
- package/dist/session/agentAdapter.js +38 -0
- package/dist/session/agentAdapter.js.map +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -0
- package/dist/session/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/agentAdapter.ts — the single adapter from the session projection
|
|
3
|
+
* to the AgentHarness message list (Exit-1 E1.1).
|
|
4
|
+
*
|
|
5
|
+
* `deriveMessages()` is the only model-history path (ADR-0016/0021); this
|
|
6
|
+
* adapter is the only way those `DerivedMessage`s become the `AgentMessage[]`
|
|
7
|
+
* fed to the harness. Hosts (CLI headless, TUI, Desktop) must not build model
|
|
8
|
+
* history any other way — model-visible ⟺ logged.
|
|
9
|
+
*
|
|
10
|
+
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
+
* - `seq` (provenance) has no AgentMessage equivalent — audits read it from
|
|
12
|
+
* the spine, not from the harness input.
|
|
13
|
+
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
|
+
* output text is already in `content`, the semantics stay in the log.
|
|
15
|
+
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
16
|
+
* assistant messages (see deriveMessages); providers that need structured
|
|
17
|
+
* `tool_calls` blocks rebuild them from `pairToolCalls()` — this adapter
|
|
18
|
+
* deliberately does NOT parse the JSON back into `AgentMessage.toolCalls`:
|
|
19
|
+
* one derived message → one agent message, nothing invented.
|
|
20
|
+
* - `images` / `reasoningContent` are runtime-only concepts; they never come
|
|
21
|
+
* from the spine.
|
|
22
|
+
*/
|
|
23
|
+
import type { AgentMessage } from '../core/AgentHarness.js';
|
|
24
|
+
import type { DerivedMessage } from './modelSurface.js';
|
|
25
|
+
/**
|
|
26
|
+
* Map session-derived messages onto the AgentHarness input format.
|
|
27
|
+
* Deterministic and side-effect free: the input is never mutated and the
|
|
28
|
+
* output shares no object references with it (roles/content are copied).
|
|
29
|
+
*/
|
|
30
|
+
export declare function derivedToAgentMessages(messages: readonly DerivedMessage[]): AgentMessage[];
|
|
31
|
+
//# sourceMappingURL=agentAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAdapter.d.ts","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,YAAY,EAAE,CAQhB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/agentAdapter.ts — the single adapter from the session projection
|
|
3
|
+
* to the AgentHarness message list (Exit-1 E1.1).
|
|
4
|
+
*
|
|
5
|
+
* `deriveMessages()` is the only model-history path (ADR-0016/0021); this
|
|
6
|
+
* adapter is the only way those `DerivedMessage`s become the `AgentMessage[]`
|
|
7
|
+
* fed to the harness. Hosts (CLI headless, TUI, Desktop) must not build model
|
|
8
|
+
* history any other way — model-visible ⟺ logged.
|
|
9
|
+
*
|
|
10
|
+
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
+
* - `seq` (provenance) has no AgentMessage equivalent — audits read it from
|
|
12
|
+
* the spine, not from the harness input.
|
|
13
|
+
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
|
+
* output text is already in `content`, the semantics stay in the log.
|
|
15
|
+
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
16
|
+
* assistant messages (see deriveMessages); providers that need structured
|
|
17
|
+
* `tool_calls` blocks rebuild them from `pairToolCalls()` — this adapter
|
|
18
|
+
* deliberately does NOT parse the JSON back into `AgentMessage.toolCalls`:
|
|
19
|
+
* one derived message → one agent message, nothing invented.
|
|
20
|
+
* - `images` / `reasoningContent` are runtime-only concepts; they never come
|
|
21
|
+
* from the spine.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Map session-derived messages onto the AgentHarness input format.
|
|
25
|
+
* Deterministic and side-effect free: the input is never mutated and the
|
|
26
|
+
* output shares no object references with it (roles/content are copied).
|
|
27
|
+
*/
|
|
28
|
+
export function derivedToAgentMessages(messages) {
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const m of messages) {
|
|
31
|
+
const agent = { role: m.role, content: m.content };
|
|
32
|
+
if (m.toolCallId !== undefined)
|
|
33
|
+
agent.toolCallId = m.toolCallId;
|
|
34
|
+
out.push(agent);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=agentAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAdapter.js","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAmC;IAEnC,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,KAAK,GAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACjE,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS;YAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/dist/session/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zelari/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"description": "Zelari Code core library — provider-neutral agent loop (AgentHarness), multi-agent council orchestration, and built-in skills. Used by the zelari-code CLI; consumable by other agent frontends.",
|
|
5
5
|
"author": "Anathema Studio <https://anathema-studio.com/>",
|
|
6
6
|
"license": "Apache-2.0",
|