@nuvin/agent-core 0.3.1-rc.1 → 0.4.0-rc.3

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.
@@ -1,5 +1,8 @@
1
1
  import type { ChildProcess } from "node:child_process";
2
+ import type { BashArtifactCapture, BashArtifactPublication, BashArtifactRef } from "./bash-artifact.ts";
2
3
  export type BackgroundBashStartRequest = Readonly<{
4
+ toolCallId: string;
5
+ artifact: BashArtifactCapture;
3
6
  command: string;
4
7
  description: string;
5
8
  cwd: string;
@@ -9,6 +12,7 @@ export type BackgroundBashStartRequest = Readonly<{
9
12
  }>;
10
13
  export type BackgroundBashAttachInput = Readonly<{
11
14
  child: ChildProcess;
15
+ artifact: BashArtifactCapture;
12
16
  description: string;
13
17
  commandPreview: string;
14
18
  cwd: string;
@@ -18,6 +22,12 @@ export type BackgroundBashAttached = Readonly<{
18
22
  pid: number | null;
19
23
  }>;
20
24
  export type BackgroundBashTerminalResult = Readonly<{
25
+ bashArtifactVersion: 1;
26
+ artifact: BashArtifactPublication;
27
+ processStarted: boolean;
28
+ closeConfirmed: boolean;
29
+ terminationConfirmed: boolean;
30
+ finishedAt: number;
21
31
  status: "exited" | "killed" | "error";
22
32
  exitCode: number | null;
23
33
  signal: string | null;
@@ -31,7 +41,14 @@ export type BackgroundBashStartErrorCode = "background-start-cancelled" | "backg
31
41
  /** Stable detached-only start failure that never exposes provider or OS error text. */
32
42
  export declare class BackgroundBashStartError extends Error {
33
43
  readonly code: BackgroundBashStartErrorCode;
34
- constructor(code: BackgroundBashStartErrorCode);
44
+ readonly correlation?: (BashArtifactRef & Readonly<{
45
+ shellId: string;
46
+ attemptId: string;
47
+ }>) | undefined;
48
+ constructor(code: BackgroundBashStartErrorCode, correlation?: (BashArtifactRef & Readonly<{
49
+ shellId: string;
50
+ attemptId: string;
51
+ }>) | undefined);
35
52
  }
36
53
  export type BackgroundBashInspection = Readonly<{
37
54
  description: string;
@@ -51,17 +68,6 @@ export type BackgroundBashInspection = Readonly<{
51
68
  forceRequested: boolean;
52
69
  errorCode?: string;
53
70
  }>;
54
- export type BackgroundBashReadResult = Readonly<{
55
- shellId: string;
56
- offset: number;
57
- nextOffset: number;
58
- output: string;
59
- status: "running" | "exited" | "killed" | "error";
60
- exitCode: number | null;
61
- signal: string | null;
62
- truncated: boolean;
63
- totalDropped: number;
64
- }>;
65
71
  export type BackgroundBashTerminationResult = Readonly<{
66
72
  shellId: string;
67
73
  outcome: "killed" | "already-terminal" | "failed";
@@ -73,15 +79,12 @@ export type BackgroundBashTerminationResult = Readonly<{
73
79
  forceRequested: boolean;
74
80
  }>;
75
81
  export interface BackgroundBashController {
76
- start(request: BackgroundBashStartRequest): Promise<Readonly<{
82
+ start(request: BackgroundBashStartRequest): Promise<BashArtifactRef & Readonly<{
77
83
  shellId: string;
84
+ attemptId: string;
78
85
  pid: number | null;
79
86
  status: "running";
80
87
  }>>;
81
- read(request: Readonly<{
82
- shellId: string;
83
- offset?: number;
84
- }>): Promise<BackgroundBashReadResult>;
85
88
  kill(shellId: string): Promise<BackgroundBashTerminationResult>;
86
89
  }
87
90
  //# sourceMappingURL=background-bash-controller.d.ts.map
@@ -25,6 +25,8 @@ export declare class BackgroundBashProcessStore {
25
25
  terminate(workId: string, signalAdapter?: ProcessTreeSignalAdapter, forceIfUnconfirmed?: boolean): Promise<BackgroundBashTerminationResult>;
26
26
  release(workId: string): void;
27
27
  private requestTermination;
28
+ private requestSignal;
29
+ private classifyClose;
28
30
  private confirmed;
29
31
  private failed;
30
32
  private terminationResult;
@@ -36,14 +38,4 @@ export declare class BackgroundBashProcessStore {
36
38
  private evict;
37
39
  private entry;
38
40
  }
39
- export declare function filterBackgroundBashOutput(input: Readonly<{
40
- output: string;
41
- offset: number;
42
- nextOffset: number;
43
- status: "running" | "exited" | "killed" | "error";
44
- regex?: string;
45
- }>): Readonly<{
46
- output: string;
47
- nextOffset: number;
48
- }>;
49
41
  //# sourceMappingURL=background-bash-process.d.ts.map
@@ -0,0 +1,62 @@
1
+ export declare const BASH_OUTPUT_MAX_BYTES = 67108864;
2
+ export type BashArtifactOwner = Readonly<{
3
+ profile: string;
4
+ workspace: string;
5
+ sessionId: string;
6
+ }>;
7
+ export type BashArtifactDestination = Readonly<{
8
+ owner: BashArtifactOwner;
9
+ sessionDir: string;
10
+ }>;
11
+ export type BashExecutionState = "starting" | "running" | "terminating" | "exited" | "killed" | "error" | "abandoned";
12
+ export type BashCaptureState = "capturing" | "complete" | "truncated" | "error" | "interrupted";
13
+ export type BashArtifactRef = Readonly<{
14
+ artifactId: string;
15
+ outputPath: string;
16
+ statusPath: string;
17
+ }>;
18
+ export type BashExecutionSnapshot = Readonly<{
19
+ state: BashExecutionState;
20
+ exitCode: number | null;
21
+ signal: string | null;
22
+ errorCode: string | null;
23
+ finishedAt: number | null;
24
+ }>;
25
+ export type BashArtifactStatus = BashArtifactRef & BashExecutionSnapshot & Readonly<{
26
+ version: 1;
27
+ owner: BashArtifactOwner;
28
+ toolCallId: string;
29
+ shellId?: string;
30
+ captureState: BashCaptureState;
31
+ bytesRetained: number;
32
+ maxBytes: 67108864;
33
+ truncated: boolean;
34
+ captureErrorCode: string | null;
35
+ startedAt: number;
36
+ updatedAt: number;
37
+ }>;
38
+ export type BashArtifactPublication = Readonly<{
39
+ status: BashArtifactStatus;
40
+ statusErrorCode: string | null;
41
+ }>;
42
+ export interface BashArtifactCapture {
43
+ readonly ref: BashArtifactRef;
44
+ /** Pass per-stream decoded text in arrival order; pause that source until this
45
+ * resolves. One outstanding append per source bounds caller-owned input too.
46
+ * Capture failures/capping resolve normally so both pipes can keep draining. */
47
+ append(stream: "stdout" | "stderr", decoded: string): Promise<void>;
48
+ /** Stops admission, drains accepted appends and closes output; idempotent. */
49
+ flush(): Promise<void>;
50
+ /** Terminal snapshots require flush. Storage failure returns statusErrorCode;
51
+ * the disk file is then last-known, while status contains current memory facts. */
52
+ publish(execution: BashExecutionSnapshot, shellId?: string): Promise<BashArtifactPublication>;
53
+ /** Marks released unfinished capture abandoned, never claims an OS kill. */
54
+ interrupt(): Promise<BashArtifactPublication>;
55
+ }
56
+ export declare function isBashArtifactStatus(value: unknown): value is BashArtifactStatus;
57
+ export declare function writeBashArtifactStatus(status: BashArtifactStatus): Promise<void>;
58
+ export declare function createBashArtifact(input: Readonly<{
59
+ destination: BashArtifactDestination;
60
+ toolCallId: string;
61
+ }>): Promise<BashArtifactCapture>;
62
+ //# sourceMappingURL=bash-artifact.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import type { BashExecutionTarget, ToolExecutionContext } from "../../shared/types.ts";
2
2
  import { type BackgroundBashController } from "./background-bash-controller.ts";
3
+ import { type BashArtifactCapture, type BashArtifactDestination } from "./bash-artifact.ts";
3
4
  export interface BashToolInput {
4
5
  command: string;
5
6
  description: string;
@@ -21,9 +22,20 @@ export interface BashToolOptions {
21
22
  scrubEnvKeys?: readonly string[];
22
23
  scrubEnvPrefixes?: readonly string[];
23
24
  backgroundController?: BackgroundBashController;
24
- verifyExecution?: (target: BashExecutionTarget, authorization: unknown, ctx: ToolExecutionContext) => Promise<void> | void;
25
+ artifactDestination?: () => BashArtifactDestination | undefined;
26
+ outputBudgetBytes?: number;
27
+ backgroundCapability?: "foreground-only" | "interactive-main";
28
+ trackForegroundExecution?: (execution: BashForegroundExecution) => void;
29
+ verifyExecution?: (target: BashExecutionTarget, authorization: unknown, ctx: ToolExecutionContext, phase?: "preflight" | "final") => Promise<void> | void;
25
30
  }
26
31
  export declare function resolveBashExecutionTarget(input: Pick<BashToolInput, "command" | "cwd" | "runInBackground">, options?: Pick<BashToolOptions, "allowedDirs" | "defaultCwd" | "shellPath">): BashExecutionTarget;
32
+ export interface BashForegroundExecution {
33
+ readonly artifact: BashArtifactCapture;
34
+ /** Confirmed child close, capture flush, and final status publication. */
35
+ readonly settled: Promise<void>;
36
+ /** Bounded process-tree escalation; rejects when close cannot be confirmed. */
37
+ terminate(reason: unknown): Promise<void>;
38
+ }
27
39
  export declare function createBashTool(options?: BashToolOptions): import("../../shared/types.ts").ToolDefinition<{
28
40
  description: string;
29
41
  command: string;
@@ -34,7 +46,11 @@ export declare function createBashTool(options?: BashToolOptions): import("../..
34
46
  outputRegex?: string | undefined;
35
47
  }, string, import("../../shared/types.ts").ToolOutputEnvelope, {
36
48
  type: "object";
49
+ additionalProperties: false;
37
50
  properties: {
51
+ runInBackground?: {
52
+ type: "boolean";
53
+ } | undefined;
38
54
  command: {
39
55
  type: "string";
40
56
  };
@@ -55,9 +71,6 @@ export declare function createBashTool(options?: BashToolOptions): import("../..
55
71
  type: "string";
56
72
  description: string;
57
73
  };
58
- runInBackground: {
59
- type: "boolean";
60
- };
61
74
  };
62
75
  required: readonly ["command", "description"];
63
76
  }>;
@@ -71,7 +84,11 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
71
84
  outputRegex?: string | undefined;
72
85
  }, string, import("../../shared/types.ts").ToolOutputEnvelope, {
73
86
  type: "object";
87
+ additionalProperties: false;
74
88
  properties: {
89
+ runInBackground?: {
90
+ type: "boolean";
91
+ } | undefined;
75
92
  command: {
76
93
  type: "string";
77
94
  };
@@ -92,9 +109,6 @@ export declare function createShellExecTool(options?: BashToolOptions): import("
92
109
  type: "string";
93
110
  description: string;
94
111
  };
95
- runInBackground: {
96
- type: "boolean";
97
- };
98
112
  };
99
113
  required: readonly ["command", "description"];
100
114
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvin/agent-core",
3
- "version": "0.3.1-rc.1",
3
+ "version": "0.4.0-rc.3",
4
4
  "private": false,
5
5
  "description": "Core agent, model, format, and tool primitives for Nuvin",
6
6
  "license": "Apache-2.0",
@@ -56,7 +56,7 @@
56
56
  "tsup": "^8.5.1",
57
57
  "typescript": "^6.0.2",
58
58
  "vitest": "^4.1.2",
59
- "@nuvin/config": "0.4.1-rc.0"
59
+ "@nuvin/config": "0.4.1-rc.2"
60
60
  },
61
61
  "dependencies": {
62
62
  "@anthropic-ai/sdk": "^0.82.0",
@@ -1 +0,0 @@
1
- function _0x4fade2(_0x5bb97e,_0x21f8ed,_0xf353b8,_0x401387){return _0x5061(_0x401387-0xc0,_0x5bb97e);}function _0x4d09(){var _0x366574=['mtjHzvnREw0','nteZnJaWnxzdDgjOBq','ntG3mde5shv2A2Hw','BMfTzq','nZyWnJu3og9szwPIBq','mte3mJqWnM5QCvPRwa','otKWnJi0CKTdzM1y','C3rHDgu','nJC2mteYsfzoEu1q','vhvYBIbMywLSzwq','nwP1C1bHEG','nJyYmdq5mhr3vMz3tG','vhvYBKzHAwXLzevYCM9Y'];_0x4d09=function(){return _0x366574;};return _0x4d09();}function _0x5061(_0x187ac2,_0x290d2c){_0x187ac2=_0x187ac2-0xd9;var _0x4d09ed=_0x4d09();var _0x5061b4=_0x4d09ed[_0x187ac2];if(_0x5061['tVIGqm']===undefined){var _0x39bd5b=function(_0x19aca2){var _0x8c52cc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x3c344e='',_0x4db073='';for(var _0x4b33a6=0x0,_0x4cdb0f,_0x40f2c0,_0x40f8e5=0x0;_0x40f2c0=_0x19aca2['charAt'](_0x40f8e5++);~_0x40f2c0&&(_0x4cdb0f=_0x4b33a6%0x4?_0x4cdb0f*0x40+_0x40f2c0:_0x40f2c0,_0x4b33a6++%0x4)?_0x3c344e+=String['fromCharCode'](0xff&_0x4cdb0f>>(-0x2*_0x4b33a6&0x6)):0x0){_0x40f2c0=_0x8c52cc['indexOf'](_0x40f2c0);}for(var _0xa5c81e=0x0,_0x454a9c=_0x3c344e['length'];_0xa5c81e<_0x454a9c;_0xa5c81e++){_0x4db073+='%'+('00'+_0x3c344e['charCodeAt'](_0xa5c81e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4db073);};_0x5061['ipVhgw']=_0x39bd5b,_0x5061['wSrJno']={},_0x5061['tVIGqm']=!![];}var _0x812657=_0x4d09ed[0x0],_0x2af895=_0x187ac2+_0x812657,_0x2385e5=_0x5061['wSrJno'][_0x2af895];return!_0x2385e5?(_0x5061b4=_0x5061['ipVhgw'](_0x5061b4),_0x5061['wSrJno'][_0x2af895]=_0x5061b4):_0x5061b4=_0x2385e5,_0x5061b4;}(function(_0xb26911,_0x2230f4){var _0x349df0={_0x4e4cdb:0x72,_0x2033ea:0x76,_0x1b07a1:0x79,_0x54b343:0x75,_0x28128a:0x125,_0xef7d5a:0x11e,_0x56cc8:0x128,_0x31b9a1:0x120,_0x3de844:0x74,_0x20a2eb:0x70,_0x3baf5f:0x77,_0x7bbbc5:0x12a,_0x478d8a:0x125,_0x41e4af:0x124,_0x2ef723:0x11c,_0x302988:0x116,_0x250f06:0x6f},_0x4624f9={_0x3d99ae:0x41},_0xdc457e={_0x2f771a:0x152},_0x183e74=_0xb26911();function _0x8e068b(_0x7cc24a,_0x2ba1d1,_0xc3fe2a,_0x53366a){return _0x5061(_0x7cc24a- -_0xdc457e._0x2f771a,_0x53366a);}function _0x322d7c(_0xa2ef5e,_0x5c80bb,_0x40529e,_0x405c1e){return _0x5061(_0x405c1e-_0x4624f9._0x3d99ae,_0x40529e);}while(!![]){try{var _0x16eabf=parseInt(_0x8e068b(-0x78,-0x72,-_0x349df0._0x4e4cdb,-_0x349df0._0x2033ea))/0x1+parseInt(_0x8e068b(-_0x349df0._0x1b07a1,-_0x349df0._0x54b343,-0x79,-0x73))/0x2+parseInt(_0x322d7c(_0x349df0._0x28128a,0x124,_0x349df0._0xef7d5a,0x124))/0x3*(parseInt(_0x322d7c(_0x349df0._0x56cc8,_0x349df0._0x31b9a1,0x122,0x122))/0x4)+parseInt(_0x8e068b(-_0x349df0._0x3de844,-_0x349df0._0x20a2eb,-0x70,-_0x349df0._0x3baf5f))/0x5*(-parseInt(_0x322d7c(_0x349df0._0x7bbbc5,0x126,_0x349df0._0x478d8a,0x126))/0x6)+parseInt(_0x322d7c(_0x349df0._0x41e4af,0x121,_0x349df0._0x2ef723,0x123))/0x7+-parseInt(_0x322d7c(0x123,0x120,_0x349df0._0x302988,0x11d))/0x8+-parseInt(_0x8e068b(-0x73,-0x70,-_0x349df0._0x1b07a1,-_0x349df0._0x250f06))/0x9;if(_0x16eabf===_0x2230f4)break;else _0x183e74['push'](_0x183e74['shift']());}catch(_0x2e8f86){_0x183e74['push'](_0x183e74['shift']());}}}(_0x4d09,0xc5aca));var TurnFailedError=class extends Error{[_0x4fade2(0x19b,0x1a1,0x1a0,0x19b)];constructor(_0x3c344e,_0x4db073){var _0x594fb0={_0x235745:0x40c,_0x257f59:0x418,_0x1af9ee:0x41f,_0x473c50:0x41e,_0x552153:0x418,_0x2852f0:0x1d1,_0x51a09c:0x1d6,_0x54ea04:0x410,_0x31489b:0x411,_0x3f36cb:0x418,_0x526841:0x415},_0x2d68ec={_0x21e3df:0x1d5,_0xe23698:0x276},_0x21afa3={_0x487b95:0x13b};super(_0x3c344e instanceof Error?_0x3c344e['message']:_0x76b878(_0x594fb0._0x235745,0x413,_0x594fb0._0x235745,_0x594fb0._0x257f59),{'cause':_0x3c344e}),this[_0x76b878(_0x594fb0._0x1af9ee,0x41a,_0x594fb0._0x473c50,_0x594fb0._0x552153)]=_0x265c57(-_0x594fb0._0x2852f0,-_0x594fb0._0x51a09c,-0x1d5,-0x1d1);function _0x265c57(_0x44c0bd,_0x49876e,_0x1d4678,_0x46ce68){return _0x4fade2(_0x46ce68,_0x49876e-0xd3,_0x1d4678-_0x21afa3._0x487b95,_0x44c0bd- -0x371);}function _0x76b878(_0x503be1,_0x27b111,_0x174a4b,_0x28c83f){return _0x4fade2(_0x503be1,_0x27b111-0xd9,_0x174a4b-_0x2d68ec._0x21e3df,_0x27b111-_0x2d68ec._0xe23698);}this[_0x76b878(_0x594fb0._0x54ea04,_0x594fb0._0x31489b,_0x594fb0._0x3f36cb,_0x594fb0._0x526841)]=_0x4db073;}};export{TurnFailedError};