@covia/covia-sdk 1.24.0 → 1.24.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 CHANGED
@@ -408,6 +408,10 @@ await mina.delete();
408
408
  const clone = await mina.fork("Mina-v2", { includeTimeline: true });
409
409
  ```
410
410
 
411
+ Create and fork require unused names. Use update to preserve an existing agent
412
+ and its history. Deletion normally returns `status: "TERMINATED"`; physical
413
+ removal (`remove: true`) returns `removed: true` without a status.
414
+
411
415
  #### Agent Instance
412
416
 
413
417
  | Method | Returns | Description |
package/dist/index.d.mts CHANGED
@@ -46,7 +46,6 @@ declare class Agent {
46
46
  fork(agentId: string, options?: {
47
47
  config?: Record<string, unknown>;
48
48
  includeTimeline?: boolean;
49
- overwrite?: boolean;
50
49
  }): Promise<Agent>;
51
50
  context(task?: unknown): Promise<string>;
52
51
  delete(remove?: boolean): Promise<AgentDeleteResult>;
@@ -1722,19 +1721,16 @@ declare enum AgentStatus {
1722
1721
  SUSPENDED = "SUSPENDED",
1723
1722
  TERMINATED = "TERMINATED"
1724
1723
  }
1724
+ /** Creates a new name only. Use update to preserve an existing agent and its history. */
1725
1725
  interface AgentCreateInput {
1726
1726
  agentId: string;
1727
1727
  config?: Record<string, any>;
1728
1728
  state?: Record<string, any>;
1729
- overwrite?: boolean;
1730
1729
  }
1731
1730
  interface AgentCreateResult {
1732
1731
  agentId: string;
1733
1732
  status: string;
1734
- created: boolean;
1735
- /** True when an existing SLEEPING/SUSPENDED record was updated in place
1736
- * (mutually exclusive with created). Absent on venues before 0.4. */
1737
- updated?: boolean;
1733
+ address?: string;
1738
1734
  /** Non-fatal advisories (venue 0.5+): present only when the config looks
1739
1735
  * misconfigured but create still succeeded — e.g. an Ollama model whose
1740
1736
  * tool-calling can't be confirmed, or declared tools that don't resolve
@@ -1807,7 +1803,9 @@ interface AgentDeleteInput {
1807
1803
  }
1808
1804
  interface AgentDeleteResult {
1809
1805
  agentId: string;
1810
- status: string;
1806
+ address?: string;
1807
+ /** Present on logical termination; absent on physical removal. */
1808
+ status?: string;
1811
1809
  removed?: boolean;
1812
1810
  }
1813
1811
  interface AgentSuspendResult {
@@ -1886,9 +1884,9 @@ interface AgentSessionMessage {
1886
1884
  tokens?: number;
1887
1885
  }
1888
1886
  /**
1889
- * An archived run of turns that compaction replaced with a summary
1887
+ * A legacy archived run of turns that compaction replaced with a summary
1890
1888
  * (AGENT_CONTEXT.md §1.1 `CompactedSegment`). `items` is the exact recursively
1891
- * archived vector, so no history is lost — {@link AgentSession.conversation}
1889
+ * archived vector (new frame histories use backward historyRange references), so no history is lost — {@link AgentSession.conversation}
1892
1890
  * expands it back into the transcript.
1893
1891
  */
1894
1892
  interface AgentCompactedSegment {
@@ -1936,17 +1934,17 @@ interface AgentSessionPage {
1936
1934
  offset: number;
1937
1935
  limit: number;
1938
1936
  }
1937
+ /** Forks into an unused name; replacement requires explicit deletion first. */
1939
1938
  interface AgentForkInput {
1940
1939
  sourceId: string;
1941
1940
  agentId: string;
1942
1941
  config?: Record<string, any>;
1943
1942
  includeTimeline?: boolean;
1944
- overwrite?: boolean;
1945
1943
  }
1946
1944
  interface AgentForkResult {
1947
1945
  agentId: string;
1946
+ address?: string;
1948
1947
  status: string;
1949
- created: boolean;
1950
1948
  forkedFrom: string;
1951
1949
  }
1952
1950
  interface AgentContextInput {
package/dist/index.d.ts CHANGED
@@ -46,7 +46,6 @@ declare class Agent {
46
46
  fork(agentId: string, options?: {
47
47
  config?: Record<string, unknown>;
48
48
  includeTimeline?: boolean;
49
- overwrite?: boolean;
50
49
  }): Promise<Agent>;
51
50
  context(task?: unknown): Promise<string>;
52
51
  delete(remove?: boolean): Promise<AgentDeleteResult>;
@@ -1722,19 +1721,16 @@ declare enum AgentStatus {
1722
1721
  SUSPENDED = "SUSPENDED",
1723
1722
  TERMINATED = "TERMINATED"
1724
1723
  }
1724
+ /** Creates a new name only. Use update to preserve an existing agent and its history. */
1725
1725
  interface AgentCreateInput {
1726
1726
  agentId: string;
1727
1727
  config?: Record<string, any>;
1728
1728
  state?: Record<string, any>;
1729
- overwrite?: boolean;
1730
1729
  }
1731
1730
  interface AgentCreateResult {
1732
1731
  agentId: string;
1733
1732
  status: string;
1734
- created: boolean;
1735
- /** True when an existing SLEEPING/SUSPENDED record was updated in place
1736
- * (mutually exclusive with created). Absent on venues before 0.4. */
1737
- updated?: boolean;
1733
+ address?: string;
1738
1734
  /** Non-fatal advisories (venue 0.5+): present only when the config looks
1739
1735
  * misconfigured but create still succeeded — e.g. an Ollama model whose
1740
1736
  * tool-calling can't be confirmed, or declared tools that don't resolve
@@ -1807,7 +1803,9 @@ interface AgentDeleteInput {
1807
1803
  }
1808
1804
  interface AgentDeleteResult {
1809
1805
  agentId: string;
1810
- status: string;
1806
+ address?: string;
1807
+ /** Present on logical termination; absent on physical removal. */
1808
+ status?: string;
1811
1809
  removed?: boolean;
1812
1810
  }
1813
1811
  interface AgentSuspendResult {
@@ -1886,9 +1884,9 @@ interface AgentSessionMessage {
1886
1884
  tokens?: number;
1887
1885
  }
1888
1886
  /**
1889
- * An archived run of turns that compaction replaced with a summary
1887
+ * A legacy archived run of turns that compaction replaced with a summary
1890
1888
  * (AGENT_CONTEXT.md §1.1 `CompactedSegment`). `items` is the exact recursively
1891
- * archived vector, so no history is lost — {@link AgentSession.conversation}
1889
+ * archived vector (new frame histories use backward historyRange references), so no history is lost — {@link AgentSession.conversation}
1892
1890
  * expands it back into the transcript.
1893
1891
  */
1894
1892
  interface AgentCompactedSegment {
@@ -1936,17 +1934,17 @@ interface AgentSessionPage {
1936
1934
  offset: number;
1937
1935
  limit: number;
1938
1936
  }
1937
+ /** Forks into an unused name; replacement requires explicit deletion first. */
1939
1938
  interface AgentForkInput {
1940
1939
  sourceId: string;
1941
1940
  agentId: string;
1942
1941
  config?: Record<string, any>;
1943
1942
  includeTimeline?: boolean;
1944
- overwrite?: boolean;
1945
1943
  }
1946
1944
  interface AgentForkResult {
1947
1945
  agentId: string;
1946
+ address?: string;
1948
1947
  status: string;
1949
- created: boolean;
1950
1948
  forkedFrom: string;
1951
1949
  }
1952
1950
  interface AgentContextInput {
package/dist/index.js CHANGED
@@ -1931,11 +1931,42 @@ function collectTurns(entries, out, depth = 0) {
1931
1931
  }
1932
1932
  }
1933
1933
  }
1934
+ function collectHistory(frame, out) {
1935
+ const history = frame.history;
1936
+ const start = frame.contextStart;
1937
+ if (frame.historyVersion !== void 0 && frame.historyVersion !== 1 || "conversation" in frame || !Array.isArray(history) || !Number.isSafeInteger(start) || start < 0 || start > history.length) {
1938
+ throw new Error("Invalid or unsupported agent frame history");
1939
+ }
1940
+ const pending = [[start, history.length]];
1941
+ const visited = /* @__PURE__ */ new Set();
1942
+ while (pending.length) {
1943
+ const [from, end] = pending.pop();
1944
+ for (let i = from; i < end; i++) {
1945
+ if (visited.has(i)) continue;
1946
+ visited.add(i);
1947
+ const entry = record(history[i]);
1948
+ if (!entry) continue;
1949
+ if ("historyRange" in entry) {
1950
+ const range = entry.historyRange;
1951
+ if (typeof entry.summary !== "string" || "items" in entry || !Number.isSafeInteger(entry.turns) || entry.turns < 0 || !Array.isArray(range) || range.length !== 2 || !range.every(Number.isSafeInteger) || range[0] < 0 || range[1] < range[0] || range[1] > i) {
1952
+ throw new Error("Invalid agent summary historyRange");
1953
+ }
1954
+ pending.push([i + 1, end], [range[0], range[1]]);
1955
+ break;
1956
+ }
1957
+ collectTurns([entry], out);
1958
+ }
1959
+ }
1960
+ }
1934
1961
  function sessionConversation(frames) {
1935
1962
  const turns = [];
1936
1963
  for (const frame of frames) {
1937
- const entries = record(frame)?.conversation;
1938
- if (Array.isArray(entries)) collectTurns(entries, turns);
1964
+ const value = record(frame);
1965
+ if (!value) continue;
1966
+ if ("history" in value) collectHistory(value, turns);
1967
+ else if ("historyVersion" in value || "contextStart" in value) {
1968
+ throw new Error("Invalid or unsupported agent frame history");
1969
+ } else if (Array.isArray(value.conversation)) collectTurns(value.conversation, turns);
1939
1970
  }
1940
1971
  return turns;
1941
1972
  }
package/dist/index.mjs CHANGED
@@ -1929,11 +1929,42 @@ function collectTurns(entries, out, depth = 0) {
1929
1929
  }
1930
1930
  }
1931
1931
  }
1932
+ function collectHistory(frame, out) {
1933
+ const history = frame.history;
1934
+ const start = frame.contextStart;
1935
+ if (frame.historyVersion !== void 0 && frame.historyVersion !== 1 || "conversation" in frame || !Array.isArray(history) || !Number.isSafeInteger(start) || start < 0 || start > history.length) {
1936
+ throw new Error("Invalid or unsupported agent frame history");
1937
+ }
1938
+ const pending = [[start, history.length]];
1939
+ const visited = /* @__PURE__ */ new Set();
1940
+ while (pending.length) {
1941
+ const [from, end] = pending.pop();
1942
+ for (let i = from; i < end; i++) {
1943
+ if (visited.has(i)) continue;
1944
+ visited.add(i);
1945
+ const entry = record(history[i]);
1946
+ if (!entry) continue;
1947
+ if ("historyRange" in entry) {
1948
+ const range = entry.historyRange;
1949
+ if (typeof entry.summary !== "string" || "items" in entry || !Number.isSafeInteger(entry.turns) || entry.turns < 0 || !Array.isArray(range) || range.length !== 2 || !range.every(Number.isSafeInteger) || range[0] < 0 || range[1] < range[0] || range[1] > i) {
1950
+ throw new Error("Invalid agent summary historyRange");
1951
+ }
1952
+ pending.push([i + 1, end], [range[0], range[1]]);
1953
+ break;
1954
+ }
1955
+ collectTurns([entry], out);
1956
+ }
1957
+ }
1958
+ }
1932
1959
  function sessionConversation(frames) {
1933
1960
  const turns = [];
1934
1961
  for (const frame of frames) {
1935
- const entries = record(frame)?.conversation;
1936
- if (Array.isArray(entries)) collectTurns(entries, turns);
1962
+ const value = record(frame);
1963
+ if (!value) continue;
1964
+ if ("history" in value) collectHistory(value, turns);
1965
+ else if ("historyVersion" in value || "contextStart" in value) {
1966
+ throw new Error("Invalid or unsupported agent frame history");
1967
+ } else if (Array.isArray(value.conversation)) collectTurns(value.conversation, turns);
1937
1968
  }
1938
1969
  return turns;
1939
1970
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covia/covia-sdk",
3
- "version": "1.24.0",
3
+ "version": "1.24.2",
4
4
  "description": "Typescript library for covia-ai",
5
5
  "packageManager": "pnpm@11.9.0",
6
6
  "main": "./dist/index.js",