@xenosystem/primitives 0.8.1 → 0.9.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/dist/cjs/sessions/agyNative.d.ts +90 -0
- package/dist/cjs/sessions/agyNative.js +392 -0
- package/dist/cjs/sessions/agyWire.d.ts +181 -0
- package/dist/cjs/sessions/agyWire.js +97 -0
- package/dist/cjs/sessions/convert.js +19 -2
- package/dist/cjs/sessions/index.d.ts +1 -0
- package/dist/cjs/sessions/index.js +9 -1
- package/dist/cjs/sessions/protowire.d.ts +29 -0
- package/dist/cjs/sessions/protowire.js +114 -0
- package/dist/cjs/sessions/read.js +2 -2
- package/dist/cjs/sessions/transcript.d.ts +1 -1
- package/dist/cjs/sessions/transcript.js +4 -2
- package/dist/cjs/sessions/types.d.ts +4 -0
- package/dist/cjs/sessions/write.d.ts +1 -0
- package/dist/cjs/sessions/write.js +18 -18
- package/dist/esm/sessions/agyNative.d.ts +90 -0
- package/dist/esm/sessions/agyNative.js +383 -0
- package/dist/esm/sessions/agyWire.d.ts +181 -0
- package/dist/esm/sessions/agyWire.js +94 -0
- package/dist/esm/sessions/convert.js +19 -2
- package/dist/esm/sessions/index.d.ts +1 -0
- package/dist/esm/sessions/index.js +1 -0
- package/dist/esm/sessions/protowire.d.ts +29 -0
- package/dist/esm/sessions/protowire.js +105 -0
- package/dist/esm/sessions/read.js +2 -2
- package/dist/esm/sessions/transcript.d.ts +1 -1
- package/dist/esm/sessions/transcript.js +4 -2
- package/dist/esm/sessions/types.d.ts +4 -0
- package/dist/esm/sessions/write.d.ts +1 -0
- package/dist/esm/sessions/write.js +19 -19
- package/native/win32-x64/process.node +0 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ import { losses, toTranscript } from "./transcript.js";
|
|
|
14
14
|
import { TARGETS, transcriptDir, writeSession } from "./write.js";
|
|
15
15
|
import { VENDORS } from "./types.js";
|
|
16
16
|
import { claudeProjectsDir, ownedPath } from "./owned.js";
|
|
17
|
+
import { agyEnv } from "./agyNative.js";
|
|
17
18
|
const asVendor = (v) => {
|
|
18
19
|
if (!VENDORS.includes(v))
|
|
19
20
|
throw new Error(`Unknown agent: ${v}. Known: ${VENDORS.join(', ')}.`);
|
|
@@ -42,7 +43,7 @@ async function prepare(source, target, ctx, fullRecord) {
|
|
|
42
43
|
const transcript = toTranscript(turns, subagents, { fullRecord });
|
|
43
44
|
if (!transcript.messages.length)
|
|
44
45
|
throw new Error('That session has no conversation to copy.');
|
|
45
|
-
const plan = { source: { vendor: ref.vendor, id: ref.id, title: ref.title, cwd: ref.cwd }, target: to, fidelity: t.fidelity, via: t.via, report: transcript.report, losses: losses(transcript.report, to, t.fidelity === 'handoff') };
|
|
46
|
+
const plan = { source: { vendor: ref.vendor, id: ref.id, title: ref.title, cwd: ref.cwd }, target: to, fidelity: t.fidelity, via: t.via, report: transcript.report, losses: losses(transcript.report, to, t.fidelity === 'handoff', t.tools) };
|
|
46
47
|
return { ref, turns, subagents, transcript, plan };
|
|
47
48
|
}
|
|
48
49
|
/** What a conversion WOULD do, writing nothing. The source's agent may be left out: it is found from the id. */
|
|
@@ -67,7 +68,14 @@ export async function convertSession(source, target, ctx) {
|
|
|
67
68
|
step('Verifying');
|
|
68
69
|
if (await fingerprint(ref, ctx) !== before)
|
|
69
70
|
throw new Error('The original session changed while it was being copied. Nothing was kept; try again when that agent is idle.');
|
|
70
|
-
if (written.id) {
|
|
71
|
+
if (written.id && plan.target === 'agy') {
|
|
72
|
+
// agy writes its summary row for a new conversation file when it next lists, so agy itself is asked; that listing is also what
|
|
73
|
+
// makes the row, so the copy is in agy's list from here on.
|
|
74
|
+
const out = await ctx.run('agy', ['conversations', 'list'], { env: agyEnv(ctx.stores.agy) }).catch((e) => String(e));
|
|
75
|
+
if (!out.includes(written.id))
|
|
76
|
+
throw new Error('agy does not list the copy it was given.');
|
|
77
|
+
}
|
|
78
|
+
else if (written.id) {
|
|
71
79
|
const seen = await findSession(plan.target, written.id, ctx).catch(() => null);
|
|
72
80
|
if (!seen)
|
|
73
81
|
throw new Error(`${plan.target} does not list the copy it was given.`);
|
|
@@ -147,6 +155,15 @@ export async function removeArtifacts(artifacts, ctx) {
|
|
|
147
155
|
throw new Error(`not an opencode session id: ${a.id}`);
|
|
148
156
|
await ctx.run('opencode', ['session', 'delete', a.id]);
|
|
149
157
|
}
|
|
158
|
+
else if (a.vendor === 'agy') {
|
|
159
|
+
// agy's own delete, which also drops its summary row and the brain folder it made when the copy was opened.
|
|
160
|
+
if (!/^[0-9a-f-]{36}$/i.test(a.id))
|
|
161
|
+
throw new Error(`not an agy conversation id: ${a.id}`);
|
|
162
|
+
await ctx.run('agy', ['conversations', 'clean', '--yes', a.id], { env: agyEnv(ctx.stores.agy) });
|
|
163
|
+
const left = join(ctx.stores.agy, 'conversations', `${a.id}.db`);
|
|
164
|
+
if (existsSync(left))
|
|
165
|
+
throw new Error(`agy did not delete ${left}`);
|
|
166
|
+
}
|
|
150
167
|
else
|
|
151
168
|
throw new Error(`no deletion path for a ${a.vendor} session`);
|
|
152
169
|
}
|
|
@@ -12,3 +12,4 @@ export { buildLayers, layersPrompt, RECENT_CAP, type Layer, type Layers } from '
|
|
|
12
12
|
export { TARGETS, writeSession, handoffDocument, claudeLines, slugForCwd, transcriptDir, type Artifact, type Written, type WriteContext } from './write.ts';
|
|
13
13
|
export { planConversion, convertSession, removeArtifacts, fingerprint, locateSession, type Plan, type Conversion, type SourceSpec } from './convert.ts';
|
|
14
14
|
export { ownedPath, claudeProjectsDir } from './owned.ts';
|
|
15
|
+
export { writeAgyConversation, agySteps, agyTool, agyEnv, userKind, AGY_STEP_CAP, AGY_TOTAL_CAP, type AgyWritten, type AgyReport } from './agyNative.ts';
|
|
@@ -12,3 +12,4 @@ export { buildLayers, layersPrompt, RECENT_CAP } from "./layers.js";
|
|
|
12
12
|
export { TARGETS, writeSession, handoffDocument, claudeLines, slugForCwd, transcriptDir } from "./write.js";
|
|
13
13
|
export { planConversion, convertSession, removeArtifacts, fingerprint, locateSession } from "./convert.js";
|
|
14
14
|
export { ownedPath, claudeProjectsDir } from "./owned.js";
|
|
15
|
+
export { writeAgyConversation, agySteps, agyTool, agyEnv, userKind, AGY_STEP_CAP, AGY_TOTAL_CAP } from "./agyNative.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protobuf wire format, the part a writer needs: varints, length-delimited fields and nested messages, and a reader for tests.
|
|
3
|
+
* Written here because the package carries no runtime dependency; the schema it encodes against is agy's own (agyWire.ts).
|
|
4
|
+
*
|
|
5
|
+
* A message is built as a list of fields in field-number order, the order protobuf encoders emit, so the bytes match what agy writes.
|
|
6
|
+
*/
|
|
7
|
+
/** A field value: a number (varint), a string or bytes (length-delimited), a nested message, or a list of any of these (repeated). */
|
|
8
|
+
export type Value = number | bigint | boolean | string | Uint8Array | Msg | Value[] | null | undefined;
|
|
9
|
+
/** A message as field number to value. Absent, null, undefined, false, 0 and '' are left out, as proto3 does for defaults. */
|
|
10
|
+
export type Msg = {
|
|
11
|
+
[field: number]: Value;
|
|
12
|
+
};
|
|
13
|
+
/** Encode a message. A nested message that is empty is still written when it is given as `{}` explicitly inside a list or as a value. */
|
|
14
|
+
export declare function encode(m: Msg): Uint8Array;
|
|
15
|
+
/** A map<string, string> field: protobuf writes each entry as a message of key (1) and value (2). */
|
|
16
|
+
export declare const mapEntries: (o: Record<string, string>) => Msg[];
|
|
17
|
+
/** A google.protobuf.Timestamp for an ISO time or epoch milliseconds. */
|
|
18
|
+
export declare function timestamp(at: string | number | null | undefined, fallbackMs: number): Msg;
|
|
19
|
+
export interface Field {
|
|
20
|
+
n: number;
|
|
21
|
+
wire: number;
|
|
22
|
+
int?: bigint;
|
|
23
|
+
bytes?: Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
/** Split one message into its raw fields, in order. */
|
|
26
|
+
export declare function fields(b: Uint8Array): Field[];
|
|
27
|
+
/** Follow a path of field numbers through nested messages and answer every value found at its end. */
|
|
28
|
+
export declare function at(b: Uint8Array, ...path: number[]): Field[];
|
|
29
|
+
export declare const text: (f: Field | undefined) => string | undefined;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protobuf wire format, the part a writer needs: varints, length-delimited fields and nested messages, and a reader for tests.
|
|
3
|
+
* Written here because the package carries no runtime dependency; the schema it encodes against is agy's own (agyWire.ts).
|
|
4
|
+
*
|
|
5
|
+
* A message is built as a list of fields in field-number order, the order protobuf encoders emit, so the bytes match what agy writes.
|
|
6
|
+
*/
|
|
7
|
+
function varint(n, out) {
|
|
8
|
+
let v = BigInt.asUintN(64, BigInt(n));
|
|
9
|
+
while (v > 0x7fn) {
|
|
10
|
+
out.push(Number(v & 0x7fn) | 0x80);
|
|
11
|
+
v >>= 7n;
|
|
12
|
+
}
|
|
13
|
+
out.push(Number(v));
|
|
14
|
+
}
|
|
15
|
+
const utf8 = new TextEncoder();
|
|
16
|
+
function isMsg(v) { return typeof v === 'object' && v !== null && !(v instanceof Uint8Array) && !Array.isArray(v); }
|
|
17
|
+
function field(n, v, out) {
|
|
18
|
+
if (v === undefined || v === null || v === false || v === 0 || v === 0n || v === '')
|
|
19
|
+
return;
|
|
20
|
+
if (Array.isArray(v)) {
|
|
21
|
+
for (const item of v)
|
|
22
|
+
field(n, item, out);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (typeof v === 'number' || typeof v === 'bigint' || typeof v === 'boolean') {
|
|
26
|
+
if (typeof v === 'number' && !Number.isInteger(v))
|
|
27
|
+
throw new Error(`field ${n}: ${v} is not an integer`);
|
|
28
|
+
varint(n << 3, out);
|
|
29
|
+
varint(v === true ? 1 : v, out);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const bytes = typeof v === 'string' ? utf8.encode(v) : v instanceof Uint8Array ? v : encode(v);
|
|
33
|
+
varint((n << 3) | 2, out);
|
|
34
|
+
varint(bytes.length, out);
|
|
35
|
+
for (const b of bytes)
|
|
36
|
+
out.push(b);
|
|
37
|
+
}
|
|
38
|
+
/** Encode a message. A nested message that is empty is still written when it is given as `{}` explicitly inside a list or as a value. */
|
|
39
|
+
export function encode(m) {
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const k of Object.keys(m).map(Number).sort((a, b) => a - b)) {
|
|
42
|
+
const v = m[k];
|
|
43
|
+
// An explicitly empty nested message is meaningful (agy writes `repository {}`), so it is kept, unlike an empty scalar.
|
|
44
|
+
if (isMsg(v) && Object.keys(v).length === 0) {
|
|
45
|
+
varint((k << 3) | 2, out);
|
|
46
|
+
out.push(0);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
field(k, v, out);
|
|
50
|
+
}
|
|
51
|
+
return Uint8Array.from(out);
|
|
52
|
+
}
|
|
53
|
+
/** A map<string, string> field: protobuf writes each entry as a message of key (1) and value (2). */
|
|
54
|
+
export const mapEntries = (o) => Object.entries(o).map(([k, v]) => ({ 1: k, 2: v }));
|
|
55
|
+
/** A google.protobuf.Timestamp for an ISO time or epoch milliseconds. */
|
|
56
|
+
export function timestamp(at, fallbackMs) {
|
|
57
|
+
const ms = typeof at === 'number' ? at : at ? Date.parse(at) : NaN;
|
|
58
|
+
const t = Number.isFinite(ms) ? ms : fallbackMs;
|
|
59
|
+
return { 1: Math.floor(t / 1000), 2: Math.round((t % 1000) * 1e6) || 0 };
|
|
60
|
+
}
|
|
61
|
+
/** Split one message into its raw fields, in order. */
|
|
62
|
+
export function fields(b) {
|
|
63
|
+
const out = [];
|
|
64
|
+
let i = 0;
|
|
65
|
+
const read = () => { let s = 0n, v = 0n; for (;;) {
|
|
66
|
+
if (i >= b.length)
|
|
67
|
+
throw new Error('truncated varint');
|
|
68
|
+
const c = b[i++];
|
|
69
|
+
v |= BigInt(c & 0x7f) << s;
|
|
70
|
+
if (!(c & 0x80))
|
|
71
|
+
return v;
|
|
72
|
+
s += 7n;
|
|
73
|
+
} };
|
|
74
|
+
while (i < b.length) {
|
|
75
|
+
const tag = Number(read()), n = tag >> 3, wire = tag & 7;
|
|
76
|
+
if (wire === 0)
|
|
77
|
+
out.push({ n, wire, int: read() });
|
|
78
|
+
else if (wire === 2) {
|
|
79
|
+
const len = Number(read());
|
|
80
|
+
if (i + len > b.length)
|
|
81
|
+
throw new Error('truncated field');
|
|
82
|
+
out.push({ n, wire, bytes: b.subarray(i, i + len) });
|
|
83
|
+
i += len;
|
|
84
|
+
}
|
|
85
|
+
else if (wire === 1) {
|
|
86
|
+
out.push({ n, wire, bytes: b.subarray(i, i + 8) });
|
|
87
|
+
i += 8;
|
|
88
|
+
}
|
|
89
|
+
else if (wire === 5) {
|
|
90
|
+
out.push({ n, wire, bytes: b.subarray(i, i + 4) });
|
|
91
|
+
i += 4;
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
throw new Error(`unsupported wire type ${wire}`);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/** Follow a path of field numbers through nested messages and answer every value found at its end. */
|
|
99
|
+
export function at(b, ...path) {
|
|
100
|
+
let level = [{ n: 0, wire: 2, bytes: b }];
|
|
101
|
+
for (const n of path)
|
|
102
|
+
level = level.flatMap((f) => (f.bytes ? fields(f.bytes) : []).filter((x) => x.n === n));
|
|
103
|
+
return level;
|
|
104
|
+
}
|
|
105
|
+
export const text = (f) => (f?.bytes ? new TextDecoder().decode(f.bytes) : undefined);
|
|
@@ -169,7 +169,7 @@ const claude = {
|
|
|
169
169
|
const text = typeof q.prompt === 'string' ? q.prompt : blocksText(q.prompt);
|
|
170
170
|
const last = turns[turns.length - 1];
|
|
171
171
|
if (text.trim() && !(last?.role === 'user' && last.text === text))
|
|
172
|
-
turns.push({ role: 'user', text, at: q.timestamp ?? at, ...(q.origin?.kind === 'human' ? {} : { from: q.origin?.kind === 'peer' ? 'peer' : 'harness' }) });
|
|
172
|
+
turns.push({ role: 'user', text, at: q.timestamp ?? at, ...(q.origin?.kind === 'human' ? { queued: true } : { from: q.origin?.kind === 'peer' ? 'peer' : 'harness' }) });
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
if (r.type === 'system' && r.subtype === 'compact_boundary') {
|
|
@@ -190,7 +190,7 @@ const claude = {
|
|
|
190
190
|
if (b?.type === 'text' && !r.isMeta)
|
|
191
191
|
turns.push({ role: 'user', text: b.text, at });
|
|
192
192
|
else if (b?.type === 'tool_result')
|
|
193
|
-
turns.push({ role: 'tool', text: '', callId: b.tool_use_id, output: kept(blocksText(b.content)), at });
|
|
193
|
+
turns.push({ role: 'tool', text: '', callId: b.tool_use_id, output: kept(blocksText(b.content)), at, ...(b.is_error ? { isError: true } : {}) });
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
else if (r.type === 'assistant') {
|
|
@@ -40,4 +40,4 @@ export declare function toTranscript(turns: Turn[], subagents?: Subagent[], opts
|
|
|
40
40
|
fullRecord?: string;
|
|
41
41
|
}): Transcript;
|
|
42
42
|
/** What the move loses, in plain words, for a person to read before it runs. */
|
|
43
|
-
export declare function losses(report: Report, target: string, handoff: boolean): string[];
|
|
43
|
+
export declare function losses(report: Report, target: string, handoff: boolean, tools?: 'native' | 'text'): string[];
|
|
@@ -96,11 +96,13 @@ export function toTranscript(turns, subagents = [], opts = {}) {
|
|
|
96
96
|
return { messages: kept, report };
|
|
97
97
|
}
|
|
98
98
|
/** What the move loses, in plain words, for a person to read before it runs. */
|
|
99
|
-
export function losses(report, target, handoff) {
|
|
99
|
+
export function losses(report, target, handoff, tools = 'text') {
|
|
100
100
|
const s = (n) => n === 1 ? '' : 's';
|
|
101
101
|
return [
|
|
102
102
|
report.thinkingDropped && `${report.thinkingDropped} thinking block${s(report.thinkingDropped)} dropped (signed by the original agent; never forged)`,
|
|
103
|
-
report.toolCalls &&
|
|
103
|
+
report.toolCalls && (tools === 'native'
|
|
104
|
+
? `${report.toolCalls} tool call${s(report.toolCalls)} ${report.toolCalls === 1 ? 'becomes' : 'become'} ${target}'s own tool step${s(report.toolCalls)}, with ${report.toolCalls === 1 ? 'its' : 'their'} results (they are not run again)`
|
|
105
|
+
: `${report.toolCalls} tool call${s(report.toolCalls)} ${report.toolCalls === 1 ? 'becomes' : 'become'} labelled text (${target} cannot re-run another agent's tools)`),
|
|
104
106
|
// A hand-over IS the full record, so only a resumable copy leaves anything out.
|
|
105
107
|
!handoff && report.omitted && `the ${report.omitted} earliest message${s(report.omitted)} left out of the resumable copy (over the copy limit; it keeps the most recent part and points to the full record of the whole conversation, written beside it)`,
|
|
106
108
|
report.truncated && `${report.truncated} long output${s(report.truncated)} shortened`,
|
|
@@ -40,6 +40,10 @@ export interface Turn {
|
|
|
40
40
|
* harness (a finished background job, 'harness'). Absent for the person's own words.
|
|
41
41
|
*/
|
|
42
42
|
from?: 'peer' | 'harness';
|
|
43
|
+
/** The person typed it while a turn was running (Claude Code keeps those as `queued_command`); agy marks them `is_queued_message`. */
|
|
44
|
+
queued?: boolean;
|
|
45
|
+
/** A tool result the agent recorded as an error (Claude Code's `is_error`). */
|
|
46
|
+
isError?: boolean;
|
|
43
47
|
}
|
|
44
48
|
/** A sub-agent's own conversation, which some agents (Claude Code) keep in separate files. */
|
|
45
49
|
export interface Subagent {
|
|
@@ -4,6 +4,7 @@ import type { Runner, SessionRef, Stores, Subagent, Turn, Vendor } from './types
|
|
|
4
4
|
export declare const TARGETS: Readonly<Record<Vendor, {
|
|
5
5
|
fidelity: 'native' | 'handoff';
|
|
6
6
|
via: string;
|
|
7
|
+
tools: 'native' | 'text';
|
|
7
8
|
}>>;
|
|
8
9
|
/** What a writer created, so a caller can remove exactly that and nothing else. */
|
|
9
10
|
export type Artifact = {
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
* private home (it reads only Claude files under its detection root)
|
|
10
10
|
* opencode `opencode import <export.json>`, recording a model opencode itself lists
|
|
11
11
|
* XENO agent `sessions/<id>/{meta.json,transcript.jsonl}` in its documented layout
|
|
12
|
-
* agy
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* agy a new `conversations/<id>.db` in agy's own format, with the schema taken from agy.exe (agyNative.ts): agy lists it,
|
|
13
|
+
* resumes it with `--conversation` and writes its own summary row. agy has no import command, so this one file is
|
|
14
|
+
* the target's own layout (as for Claude Code and the XENO agent); the list database is never written. Each tool
|
|
15
|
+
* call becomes agy's own tool step, drawn as agy draws its own (owner, 2026-11-28: "proper session resume not
|
|
16
|
+
* handover", "loops, goals, commands … full scale … 1:1 in the interface").
|
|
15
17
|
* Every copy also carries the full record of the original in `<workDir>/transcript/` (layers.ts), so nothing the copy itself cannot
|
|
16
18
|
* hold is lost. Every file is created exclusively at its final name, so nothing that exists is ever replaced.
|
|
17
19
|
*/
|
|
@@ -21,15 +23,16 @@ import { dirname, join, resolve, sep } from 'node:path';
|
|
|
21
23
|
import { spawnAgent } from "./run.js";
|
|
22
24
|
import { safeSessionId } from "./read.js";
|
|
23
25
|
import { cap } from "./transcript.js";
|
|
24
|
-
import { buildLayers
|
|
26
|
+
import { buildLayers } from "./layers.js";
|
|
25
27
|
import { claudeProjectsDir, ownedPath } from "./owned.js";
|
|
28
|
+
import { writeAgyConversation } from "./agyNative.js";
|
|
26
29
|
/** How each agent takes a copy, and whether it can resume it as its own conversation. */
|
|
27
30
|
export const TARGETS = Object.freeze({
|
|
28
|
-
'Claude Code': { fidelity: 'native', via: "a new session file in Claude Code's own layout" },
|
|
29
|
-
Codex: { fidelity: 'native', via: "Codex's own external-session importer (from a Claude-shaped copy)" },
|
|
30
|
-
opencode: { fidelity: 'native', via: 'opencode import' },
|
|
31
|
-
'XENO agent': { fidelity: 'native', via: "a new session in the XENO agent's own layout" },
|
|
32
|
-
agy: { fidelity: '
|
|
31
|
+
'Claude Code': { fidelity: 'native', via: "a new session file in Claude Code's own layout", tools: 'text' },
|
|
32
|
+
Codex: { fidelity: 'native', via: "Codex's own external-session importer (from a Claude-shaped copy)", tools: 'text' },
|
|
33
|
+
opencode: { fidelity: 'native', via: 'opencode import', tools: 'text' },
|
|
34
|
+
'XENO agent': { fidelity: 'native', via: "a new session in the XENO agent's own layout", tools: 'text' },
|
|
35
|
+
agy: { fidelity: 'native', via: "a new conversation file in agy's own format, resumed with agy --conversation", tools: 'native' },
|
|
33
36
|
});
|
|
34
37
|
/** Where a conversion keeps the layered record of the original, inside its own folder. */
|
|
35
38
|
export const transcriptDir = (workDir) => join(workDir, 'transcript');
|
|
@@ -214,14 +217,11 @@ export async function writeSession(target, msgs, source, ctx) {
|
|
|
214
217
|
.map((r, i) => JSON.stringify({ id: `e${i}`, timestamp: at, sequence: i, ...r })).join('\n') + '\n');
|
|
215
218
|
return { id: sid, cwd, artifacts, resume: ['--resume', sid] };
|
|
216
219
|
}
|
|
217
|
-
// agy
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
writeNew(file, doc.full);
|
|
225
|
-
record({ kind: 'file', path: file });
|
|
226
|
-
return { id: null, cwd, artifacts, handoff: { file, prompt: doc.prompt(file) } };
|
|
220
|
+
// agy: its own conversation file, from the turns themselves so every tool call keeps its kind. Without the turns (a caller that only
|
|
221
|
+
// has the portable messages), the messages become the turns.
|
|
222
|
+
const turns = ctx.layers?.turns ?? msgs.map((m) => ({ role: m.role, text: m.text, at: m.at }));
|
|
223
|
+
const full = index ? join(dirname(index), 'full.md') : undefined;
|
|
224
|
+
const written = await writeAgyConversation(turns, ctx.layers?.subagents ?? [], { store: ctx.stores.agy, cwd, ...(full ? { fullRecord: full } : {}) });
|
|
225
|
+
record({ kind: 'vendor-session', vendor: 'agy', id: written.id });
|
|
226
|
+
return { id: written.id, cwd, artifacts, resume: ['--conversation', written.id] };
|
|
227
227
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenosystem/primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "XENO back-end rung 1 primitives: dirs (the XENO local home), secrets (envelope-encrypted credentials), updates (the gated app updater), live (the client for XENO Multiplayer) process (start a command so that stopping it stops everything it started), private-file (owner-only files, published atomically, without a helper process) and sessions (one conversation format with a reader and a writer for each agent, so a session moves between Claude Code, Codex, agy, opencode and the XENO agent).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|