@celljs/ai-coding-agent 4.4.1 → 4.5.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/esm/node/pi/index.d.ts +1 -0
- package/esm/node/pi/index.js +1 -0
- package/esm/node/pi/index.js.map +1 -1
- package/esm/node/pi/pi-bundle-util.d.ts +13 -0
- package/esm/node/pi/pi-bundle-util.js +42 -0
- package/esm/node/pi/pi-bundle-util.js.map +1 -0
- package/esm/node/pi/pi-sdk-util.js +2 -1
- package/esm/node/pi/pi-sdk-util.js.map +1 -1
- package/esm/node/session/agent-session-factory.d.ts +1 -3
- package/esm/node/session/agent-session-factory.js +2 -14
- package/esm/node/session/agent-session-factory.js.map +1 -1
- package/esm/node/session/agent-tool-util.d.ts +6 -0
- package/esm/node/session/agent-tool-util.js +18 -0
- package/esm/node/session/agent-tool-util.js.map +1 -0
- package/esm/node/session/index.d.ts +1 -0
- package/esm/node/session/index.js +1 -0
- package/esm/node/session/index.js.map +1 -1
- package/lib/node/pi/index.d.ts +1 -0
- package/lib/node/pi/index.d.ts.map +1 -1
- package/lib/node/pi/index.js +1 -0
- package/lib/node/pi/index.js.map +1 -1
- package/lib/node/pi/pi-bundle-util.d.ts +14 -0
- package/lib/node/pi/pi-bundle-util.d.ts.map +1 -0
- package/lib/node/pi/pi-bundle-util.js +41 -0
- package/lib/node/pi/pi-bundle-util.js.map +1 -0
- package/lib/node/pi/pi-bundle-util.spec.d.ts +2 -0
- package/lib/node/pi/pi-bundle-util.spec.d.ts.map +1 -0
- package/lib/node/pi/pi-bundle-util.spec.js +42 -0
- package/lib/node/pi/pi-bundle-util.spec.js.map +1 -0
- package/lib/node/pi/pi-sdk-util.d.ts.map +1 -1
- package/lib/node/pi/pi-sdk-util.js +2 -1
- package/lib/node/pi/pi-sdk-util.js.map +1 -1
- package/lib/node/session/agent-session-factory.d.ts +1 -3
- package/lib/node/session/agent-session-factory.d.ts.map +1 -1
- package/lib/node/session/agent-session-factory.js +2 -14
- package/lib/node/session/agent-session-factory.js.map +1 -1
- package/lib/node/session/agent-tool-util.d.ts +7 -0
- package/lib/node/session/agent-tool-util.d.ts.map +1 -0
- package/lib/node/session/agent-tool-util.js +21 -0
- package/lib/node/session/agent-tool-util.js.map +1 -0
- package/lib/node/session/index.d.ts +1 -0
- package/lib/node/session/index.d.ts.map +1 -1
- package/lib/node/session/index.js +1 -0
- package/lib/node/session/index.js.map +1 -1
- package/package.json +4 -4
- package/src/node/pi/index.ts +1 -0
- package/src/node/pi/pi-bundle-util.spec.ts +44 -0
- package/src/node/pi/pi-bundle-util.ts +36 -0
- package/src/node/pi/pi-sdk-util.ts +2 -1
- package/src/node/session/agent-session-factory.ts +3 -15
- package/src/node/session/agent-tool-util.ts +17 -0
- package/src/node/session/index.ts +1 -0
package/esm/node/pi/index.d.ts
CHANGED
package/esm/node/pi/index.js
CHANGED
package/esm/node/pi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare namespace PiBundleUtil {
|
|
2
|
+
/**
|
|
3
|
+
* What to `import()` for pi. The package's main entry is its unbundled build; the bundle its own `pi`
|
|
4
|
+
* command runs has the same exports, starts about 6 times faster and takes 30 MB less. The package's
|
|
5
|
+
* `exports` do not list it, so it is found by path. This file imports nothing else, so that
|
|
6
|
+
* processes that never use Cell (the `ta` command) can load it without `@celljs/core`. On Bun the
|
|
7
|
+
* main entry it is: the bundle holds a copy of undici that only runs on Node.js.
|
|
8
|
+
*
|
|
9
|
+
* `PI_PACKAGE_DIR` tells pi where its package is; a bundle there comes first. A distribution of pi
|
|
10
|
+
* (ta) ships its own build of pi there.
|
|
11
|
+
*/
|
|
12
|
+
function specifier(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { fileURLToPath as __cellFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __cellDirname } from "node:path";
|
|
3
|
+
const __filename = __cellFileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __cellDirname(__filename);
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
export var PiBundleUtil;
|
|
10
|
+
(function (PiBundleUtil) {
|
|
11
|
+
const PACKAGE = '@earendil-works/pi-coding-agent';
|
|
12
|
+
const BUNDLE = 'dist/bundle/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* What to `import()` for pi. The package's main entry is its unbundled build; the bundle its own `pi`
|
|
15
|
+
* command runs has the same exports, starts about 6 times faster and takes 30 MB less. The package's
|
|
16
|
+
* `exports` do not list it, so it is found by path. This file imports nothing else, so that
|
|
17
|
+
* processes that never use Cell (the `ta` command) can load it without `@celljs/core`. On Bun the
|
|
18
|
+
* main entry it is: the bundle holds a copy of undici that only runs on Node.js.
|
|
19
|
+
*
|
|
20
|
+
* `PI_PACKAGE_DIR` tells pi where its package is; a bundle there comes first. A distribution of pi
|
|
21
|
+
* (ta) ships its own build of pi there.
|
|
22
|
+
*/
|
|
23
|
+
function specifier() {
|
|
24
|
+
var _a;
|
|
25
|
+
if (process.versions.bun) {
|
|
26
|
+
return PACKAGE;
|
|
27
|
+
}
|
|
28
|
+
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
29
|
+
if (packageDir && existsSync(join(packageDir, BUNDLE))) {
|
|
30
|
+
return pathToFileURL(join(packageDir, BUNDLE)).href;
|
|
31
|
+
}
|
|
32
|
+
for (const nodeModules of (_a = createRequire(__filename).resolve.paths(PACKAGE)) !== null && _a !== void 0 ? _a : []) {
|
|
33
|
+
const bundle = join(nodeModules, PACKAGE, BUNDLE);
|
|
34
|
+
if (existsSync(bundle)) {
|
|
35
|
+
return pathToFileURL(bundle).href;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return PACKAGE;
|
|
39
|
+
}
|
|
40
|
+
PiBundleUtil.specifier = specifier;
|
|
41
|
+
})(PiBundleUtil || (PiBundleUtil = {}));
|
|
42
|
+
//# sourceMappingURL=pi-bundle-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-bundle-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-bundle-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,KAAW,YAAY,CA8B5B;AA9BD,WAAiB,YAAY;IACzB,MAAM,OAAO,GAAG,iCAAiC,CAAC;IAClD,MAAM,MAAM,GAAG,sBAAsB,CAAC;IAEtC;;;;;;;;;OASG;IACH,SAAgB,SAAS;;QACrB,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC9C,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,CAAC;QACD,KAAK,MAAM,WAAW,UAAI,aAAa,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,mCAAI,EAAE,EAAE,CAAC;YAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAClD,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrB,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACtC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAfe,aAAA,SAAS,YAexB,CAAA;AACL,CAAC,EA9BgB,YAAY,KAAZ,YAAY,QA8B5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CodingAgentError } from '../error/index.js';
|
|
2
|
+
import { PiBundleUtil } from './pi-bundle-util.js';
|
|
2
3
|
export var PiSdkUtil;
|
|
3
4
|
(function (PiSdkUtil) {
|
|
4
5
|
let sdk;
|
|
@@ -8,7 +9,7 @@ export var PiSdkUtil;
|
|
|
8
9
|
*/
|
|
9
10
|
function load() {
|
|
10
11
|
if (!sdk) {
|
|
11
|
-
sdk = import(
|
|
12
|
+
sdk = import(/* @vite-ignore */ PiBundleUtil.specifier()).catch(cause => {
|
|
12
13
|
sdk = undefined;
|
|
13
14
|
throw new CodingAgentError('Cannot load @earendil-works/pi-coding-agent. Install it next to @celljs/ai-coding-agent; it needs Node.js >= 22.19.0 or Bun.', { cause });
|
|
14
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-sdk-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-sdk-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pi-sdk-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-sdk-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,MAAM,KAAW,SAAS,CAmBzB;AAnBD,WAAiB,SAAS;IACtB,IAAI,GAA+B,CAAC;IAEpC;;;OAGG;IACH,SAAgB,IAAI;QAChB,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,GAAG,GAAI,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,EAAE,CAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACxF,GAAG,GAAG,SAAS,CAAC;gBAChB,MAAM,IAAI,gBAAgB,CACtB,8HAA8H,EAC9H,EAAE,KAAK,EAAE,CACZ,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAXe,UAAA,IAAI,OAWnB,CAAA;AACL,CAAC,EAnBgB,SAAS,KAAT,SAAS,QAmBzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentTool } from '@celljs/ai-agent';
|
|
2
2
|
import { Logger } from '@celljs/core';
|
|
3
3
|
import { AgentExtension, AgentSessionFactory, type AgentSessionOptions, type CodingAgentOptions, ModelRuntimeProvider } from '../coding-agent-protocol.js';
|
|
4
|
-
import { type AgentSession, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk
|
|
4
|
+
import { type AgentSession, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk } from '../pi/index.js';
|
|
5
5
|
export declare class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
6
6
|
protected readonly options?: CodingAgentOptions;
|
|
7
7
|
protected readonly modelRuntimeProvider: ModelRuntimeProvider;
|
|
@@ -11,8 +11,6 @@ export declare class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
|
11
11
|
create(sessionOptions?: AgentSessionOptions): Promise<AgentSession>;
|
|
12
12
|
protected mergeOptions(sessionOptions: AgentSessionOptions): CodingAgentOptions;
|
|
13
13
|
protected createResourceLoader(sdk: PiSdk, options: CodingAgentOptions, cwd: string, agentDir: string, settingsManager: ReturnType<PiSdk['SettingsManager']['create']>): Promise<InstanceType<PiSdk['DefaultResourceLoader']>>;
|
|
14
|
-
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
15
|
-
protected toToolDefinition(tool: AgentTool): ToolDefinition;
|
|
16
14
|
/** The extensions the pi CLI loads by default, as `ai.codingAgent` turns them on. */
|
|
17
15
|
protected builtinExtensions(sdk: PiSdk, options: CodingAgentOptions): {
|
|
18
16
|
name: string;
|
|
@@ -13,6 +13,7 @@ import { Autowired, Component, Logger, Optional, Value } from '@celljs/core';
|
|
|
13
13
|
import { AgentExtension, AgentSessionFactory, CODING_AGENT_OPTIONS, ModelRuntimeProvider, } from '../coding-agent-protocol.js';
|
|
14
14
|
import { AgentExtensionError, AgentModelNotFoundError } from '../error/index.js';
|
|
15
15
|
import { PiSdkUtil } from '../pi/index.js';
|
|
16
|
+
import { AgentToolUtil } from './agent-tool-util.js';
|
|
16
17
|
let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
17
18
|
constructor() {
|
|
18
19
|
this.extensions = [];
|
|
@@ -44,7 +45,7 @@ let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
|
44
45
|
thinkingLevel: options.thinkingLevel,
|
|
45
46
|
tools: options.tools,
|
|
46
47
|
excludeTools: options.excludeTools,
|
|
47
|
-
customTools: ((_b = this.tools) !== null && _b !== void 0 ? _b : []).map(
|
|
48
|
+
customTools: ((_b = this.tools) !== null && _b !== void 0 ? _b : []).map(AgentToolUtil.toToolDefinition),
|
|
48
49
|
});
|
|
49
50
|
// Headless: extensions run without a UI, as in pi's RPC mode.
|
|
50
51
|
await session.bindExtensions({ mode: 'rpc' });
|
|
@@ -96,19 +97,6 @@ let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
|
96
97
|
}
|
|
97
98
|
return resourceLoader;
|
|
98
99
|
}
|
|
99
|
-
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
100
|
-
toToolDefinition(tool) {
|
|
101
|
-
var _a;
|
|
102
|
-
return {
|
|
103
|
-
name: tool.name,
|
|
104
|
-
label: tool.label,
|
|
105
|
-
description: tool.description,
|
|
106
|
-
parameters: tool.parameters,
|
|
107
|
-
executionMode: tool.executionMode,
|
|
108
|
-
prepareArguments: (_a = tool.prepareArguments) === null || _a === void 0 ? void 0 : _a.bind(tool),
|
|
109
|
-
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
100
|
/** The extensions the pi CLI loads by default, as `ai.codingAgent` turns them on. */
|
|
113
101
|
builtinExtensions(sdk, options) {
|
|
114
102
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-factory.js","sourceRoot":"","sources":["../../../src/node/session/agent-session-factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACH,cAAc,EACd,mBAAmB,EAEnB,oBAAoB,EAEpB,oBAAoB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAA0G,SAAS,
|
|
1
|
+
{"version":3,"file":"agent-session-factory.js","sourceRoot":"","sources":["../../../src/node/session/agent-session-factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAA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AAC,CAAC,CAAC,SAAS,CAAC;QACvG,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,uBAAuB,CAC7B,GAAG,EACH,YAAY,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CACxE,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAhJsB;IADlB,KAAK,CAAC,oBAAoB,CAAC;;2DACoB;AAG7B;IADlB,SAAS,CAAC,oBAAoB,CAAC;;wEAC8B;AAI3C;IAFlB,SAAS,CAAC,cAAc,CAAC;IACzB,QAAQ,EAAE;;8DAC0C;AAIlC;IAFlB,SAAS,CAAC,SAAS,CAAC;IACpB,QAAQ,EAAE;;yDACgC;AAGxB;IADlB,SAAS,CAAC,MAAM,CAAC;;0DACgB;AAhBzB,0BAA0B;IADtC,SAAS,CAAC,mBAAmB,CAAC;GAClB,0BAA0B,CAkJtC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentTool } from '@celljs/ai-agent';
|
|
2
|
+
import type { ToolDefinition } from '../pi/index.js';
|
|
3
|
+
export declare namespace AgentToolUtil {
|
|
4
|
+
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
5
|
+
function toToolDefinition(tool: AgentTool): ToolDefinition;
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var AgentToolUtil;
|
|
2
|
+
(function (AgentToolUtil) {
|
|
3
|
+
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
4
|
+
function toToolDefinition(tool) {
|
|
5
|
+
var _a;
|
|
6
|
+
return {
|
|
7
|
+
name: tool.name,
|
|
8
|
+
label: tool.label,
|
|
9
|
+
description: tool.description,
|
|
10
|
+
parameters: tool.parameters,
|
|
11
|
+
executionMode: tool.executionMode,
|
|
12
|
+
prepareArguments: (_a = tool.prepareArguments) === null || _a === void 0 ? void 0 : _a.bind(tool),
|
|
13
|
+
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
AgentToolUtil.toToolDefinition = toToolDefinition;
|
|
17
|
+
})(AgentToolUtil || (AgentToolUtil = {}));
|
|
18
|
+
//# sourceMappingURL=agent-tool-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-util.js","sourceRoot":"","sources":["../../../src/node/session/agent-tool-util.ts"],"names":[],"mappings":"AAGA,MAAM,KAAW,aAAa,CAa7B;AAbD,WAAiB,aAAa;IAC1B,sHAAsH;IACtH,SAAgB,gBAAgB,CAAC,IAAe;;QAC5C,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,MAAA,IAAI,CAAC,gBAAgB,0CAAE,IAAI,CAAC,IAAI,CAAC;YACnD,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAa,EAAE,MAAM,EAAE,QAAe,CAAC;SACpG,CAAC;IACxB,CAAC;IAVe,cAAA,gBAAgB,mBAU/B,CAAA;AACL,CAAC,EAbgB,aAAa,KAAb,aAAa,QAa7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
package/lib/node/pi/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/lib/node/pi/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./pi-bundle-util"), exports);
|
|
17
18
|
__exportStar(require("./pi-sdk-util"), exports);
|
|
18
19
|
__exportStar(require("./pi-types"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/lib/node/pi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/pi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B;AAC9B,6CAA2B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare namespace PiBundleUtil {
|
|
2
|
+
/**
|
|
3
|
+
* What to `import()` for pi. The package's main entry is its unbundled build; the bundle its own `pi`
|
|
4
|
+
* command runs has the same exports, starts about 6 times faster and takes 30 MB less. The package's
|
|
5
|
+
* `exports` do not list it, so it is found by path. This file imports nothing else, so that
|
|
6
|
+
* processes that never use Cell (the `ta` command) can load it without `@celljs/core`. On Bun the
|
|
7
|
+
* main entry it is: the bundle holds a copy of undici that only runs on Node.js.
|
|
8
|
+
*
|
|
9
|
+
* `PI_PACKAGE_DIR` tells pi where its package is; a bundle there comes first. A distribution of pi
|
|
10
|
+
* (ta) ships its own build of pi there.
|
|
11
|
+
*/
|
|
12
|
+
function specifier(): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=pi-bundle-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-bundle-util.d.ts","sourceRoot":"","sources":["../../../src/node/pi/pi-bundle-util.ts"],"names":[],"mappings":"AAKA,yBAAiB,YAAY,CAAC;IAI1B;;;;;;;;;OASG;IACH,SAAgB,SAAS,IAAI,MAAM,CAelC;CACJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PiBundleUtil = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_module_1 = require("node:module");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
8
|
+
var PiBundleUtil;
|
|
9
|
+
(function (PiBundleUtil) {
|
|
10
|
+
const PACKAGE = '@earendil-works/pi-coding-agent';
|
|
11
|
+
const BUNDLE = 'dist/bundle/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* What to `import()` for pi. The package's main entry is its unbundled build; the bundle its own `pi`
|
|
14
|
+
* command runs has the same exports, starts about 6 times faster and takes 30 MB less. The package's
|
|
15
|
+
* `exports` do not list it, so it is found by path. This file imports nothing else, so that
|
|
16
|
+
* processes that never use Cell (the `ta` command) can load it without `@celljs/core`. On Bun the
|
|
17
|
+
* main entry it is: the bundle holds a copy of undici that only runs on Node.js.
|
|
18
|
+
*
|
|
19
|
+
* `PI_PACKAGE_DIR` tells pi where its package is; a bundle there comes first. A distribution of pi
|
|
20
|
+
* (ta) ships its own build of pi there.
|
|
21
|
+
*/
|
|
22
|
+
function specifier() {
|
|
23
|
+
var _a;
|
|
24
|
+
if (process.versions.bun) {
|
|
25
|
+
return PACKAGE;
|
|
26
|
+
}
|
|
27
|
+
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
28
|
+
if (packageDir && (0, node_fs_1.existsSync)((0, node_path_1.join)(packageDir, BUNDLE))) {
|
|
29
|
+
return (0, node_url_1.pathToFileURL)((0, node_path_1.join)(packageDir, BUNDLE)).href;
|
|
30
|
+
}
|
|
31
|
+
for (const nodeModules of (_a = (0, node_module_1.createRequire)(__filename).resolve.paths(PACKAGE)) !== null && _a !== void 0 ? _a : []) {
|
|
32
|
+
const bundle = (0, node_path_1.join)(nodeModules, PACKAGE, BUNDLE);
|
|
33
|
+
if ((0, node_fs_1.existsSync)(bundle)) {
|
|
34
|
+
return (0, node_url_1.pathToFileURL)(bundle).href;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return PACKAGE;
|
|
38
|
+
}
|
|
39
|
+
PiBundleUtil.specifier = specifier;
|
|
40
|
+
})(PiBundleUtil || (exports.PiBundleUtil = PiBundleUtil = {}));
|
|
41
|
+
//# sourceMappingURL=pi-bundle-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-bundle-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-bundle-util.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,6CAA4C;AAC5C,yCAAiC;AACjC,uCAAyC;AAEzC,IAAiB,YAAY,CA8B5B;AA9BD,WAAiB,YAAY;IACzB,MAAM,OAAO,GAAG,iCAAiC,CAAC;IAClD,MAAM,MAAM,GAAG,sBAAsB,CAAC;IAEtC;;;;;;;;;OASG;IACH,SAAgB,SAAS;;QACrB,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC9C,IAAI,UAAU,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,IAAA,wBAAa,EAAC,IAAA,gBAAI,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,CAAC;QACD,KAAK,MAAM,WAAW,UAAI,IAAA,2BAAa,EAAC,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,mCAAI,EAAE,EAAE,CAAC;YAC/E,MAAM,MAAM,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAClD,IAAI,IAAA,oBAAU,EAAC,MAAM,CAAC,EAAE,CAAC;gBACrB,OAAO,IAAA,wBAAa,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACtC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAfe,aAAA,SAAS,YAexB,CAAA;AACL,CAAC,EA9BgB,YAAY,aAAZ,YAAY,GAAZ,YAAY,QA8B5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-bundle-util.spec.d.ts","sourceRoot":"","sources":["../../../src/node/pi/pi-bundle-util.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_os_1 = require("node:os");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
8
|
+
const pi_bundle_util_1 = require("./pi-bundle-util");
|
|
9
|
+
(0, bun_test_1.describe)('PiBundleUtil', () => {
|
|
10
|
+
const bun = process.versions.bun;
|
|
11
|
+
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
12
|
+
(0, bun_test_1.afterEach)(() => {
|
|
13
|
+
Object.assign(process.versions, { bun });
|
|
14
|
+
if (packageDir === undefined) {
|
|
15
|
+
delete process.env.PI_PACKAGE_DIR;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
process.env.PI_PACKAGE_DIR = packageDir;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
function onNode() {
|
|
22
|
+
// process.versions is writable in Bun; the check is all specifier() looks at.
|
|
23
|
+
Object.assign(process.versions, { bun: undefined });
|
|
24
|
+
}
|
|
25
|
+
(0, bun_test_1.it)('loads the bundle in the package directory pi is told about first', () => {
|
|
26
|
+
onNode();
|
|
27
|
+
const dir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'pi-package-'));
|
|
28
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(dir, 'dist/bundle'), { recursive: true });
|
|
29
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(dir, 'dist/bundle/index.js'), '');
|
|
30
|
+
process.env.PI_PACKAGE_DIR = dir;
|
|
31
|
+
(0, bun_test_1.expect)(pi_bundle_util_1.PiBundleUtil.specifier()).toBe((0, node_url_1.pathToFileURL)((0, node_path_1.join)(dir, 'dist/bundle/index.js')).href);
|
|
32
|
+
});
|
|
33
|
+
(0, bun_test_1.it)('loads the installed bundle when that directory has none', () => {
|
|
34
|
+
onNode();
|
|
35
|
+
process.env.PI_PACKAGE_DIR = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'pi-package-'));
|
|
36
|
+
(0, bun_test_1.expect)(pi_bundle_util_1.PiBundleUtil.specifier()).toEndWith('/@earendil-works/pi-coding-agent/dist/bundle/index.js');
|
|
37
|
+
});
|
|
38
|
+
(0, bun_test_1.it)('loads the package entry on Bun, which cannot run the bundle', () => {
|
|
39
|
+
(0, bun_test_1.expect)(pi_bundle_util_1.PiBundleUtil.specifier()).toBe('@earendil-works/pi-coding-agent');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=pi-bundle-util.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-bundle-util.spec.js","sourceRoot":"","sources":["../../../src/node/pi/pi-bundle-util.spec.ts"],"names":[],"mappings":";;AAAA,uCAA2D;AAC3D,qCAAgE;AAChE,qCAAiC;AACjC,yCAAiC;AACjC,uCAAyC;AACzC,qDAAgD;AAEhD,IAAA,mBAAQ,EAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAE9C,IAAA,oBAAS,EAAC,GAAG,EAAE;QACX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACzC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QACtC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,UAAU,CAAC;QAC5C,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,MAAM;QACX,8EAA8E;QAC9E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,IAAA,aAAE,EAAC,kEAAkE,EAAE,GAAG,EAAE;QACxE,MAAM,EAAE,CAAC;QACT,MAAM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-util.d.ts","sourceRoot":"","sources":["../../../src/node/pi/pi-sdk-util.ts"],"names":[],"mappings":"AAGA,iEAAiE;AACjE,MAAM,MAAM,KAAK,GAAG,cAAc,iCAAiC,EAAU,UAAE,iBAAiB,EAAE,QAAQ,IAAE,CAAE,CAAC;AAE/G,yBAAiB,SAAS,CAAC;IAGvB;;;OAGG;IACH,SAAgB,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAWrC;CACJ"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PiSdkUtil = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
|
+
const pi_bundle_util_1 = require("./pi-bundle-util");
|
|
5
6
|
var PiSdkUtil;
|
|
6
7
|
(function (PiSdkUtil) {
|
|
7
8
|
let sdk;
|
|
@@ -11,7 +12,7 @@ var PiSdkUtil;
|
|
|
11
12
|
*/
|
|
12
13
|
function load() {
|
|
13
14
|
if (!sdk) {
|
|
14
|
-
sdk = import(
|
|
15
|
+
sdk = import(/* @vite-ignore */ pi_bundle_util_1.PiBundleUtil.specifier()).catch(cause => {
|
|
15
16
|
sdk = undefined;
|
|
16
17
|
throw new error_1.CodingAgentError('Cannot load @earendil-works/pi-coding-agent. Install it next to @celljs/ai-coding-agent; it needs Node.js >= 22.19.0 or Bun.', { cause });
|
|
17
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-sdk-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-sdk-util.ts"],"names":[],"mappings":";;;AAAA,oCAA4C;
|
|
1
|
+
{"version":3,"file":"pi-sdk-util.js","sourceRoot":"","sources":["../../../src/node/pi/pi-sdk-util.ts"],"names":[],"mappings":";;;AAAA,oCAA4C;AAC5C,qDAAgD;AAKhD,IAAiB,SAAS,CAmBzB;AAnBD,WAAiB,SAAS;IACtB,IAAI,GAA+B,CAAC;IAEpC;;;OAGG;IACH,SAAgB,IAAI;QAChB,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,GAAG,GAAI,MAAM,CAAC,kBAAkB,CAAC,6BAAY,CAAC,SAAS,EAAE,CAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACxF,GAAG,GAAG,SAAS,CAAC;gBAChB,MAAM,IAAI,wBAAgB,CACtB,8HAA8H,EAC9H,EAAE,KAAK,EAAE,CACZ,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAXe,UAAA,IAAI,OAWnB,CAAA;AACL,CAAC,EAnBgB,SAAS,aAAT,SAAS,GAAT,SAAS,QAmBzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentTool } from '@celljs/ai-agent';
|
|
2
2
|
import { Logger } from '@celljs/core';
|
|
3
3
|
import { AgentExtension, AgentSessionFactory, type AgentSessionOptions, type CodingAgentOptions, ModelRuntimeProvider } from '../coding-agent-protocol';
|
|
4
|
-
import { type AgentSession, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk
|
|
4
|
+
import { type AgentSession, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk } from '../pi';
|
|
5
5
|
export declare class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
6
6
|
protected readonly options?: CodingAgentOptions;
|
|
7
7
|
protected readonly modelRuntimeProvider: ModelRuntimeProvider;
|
|
@@ -11,8 +11,6 @@ export declare class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
|
11
11
|
create(sessionOptions?: AgentSessionOptions): Promise<AgentSession>;
|
|
12
12
|
protected mergeOptions(sessionOptions: AgentSessionOptions): CodingAgentOptions;
|
|
13
13
|
protected createResourceLoader(sdk: PiSdk, options: CodingAgentOptions, cwd: string, agentDir: string, settingsManager: ReturnType<PiSdk['SettingsManager']['create']>): Promise<InstanceType<PiSdk['DefaultResourceLoader']>>;
|
|
14
|
-
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
15
|
-
protected toToolDefinition(tool: AgentTool): ToolDefinition;
|
|
16
14
|
/** The extensions the pi CLI loads by default, as `ai.codingAgent` turns them on. */
|
|
17
15
|
protected builtinExtensions(sdk: PiSdk, options: CodingAgentOptions): {
|
|
18
16
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-factory.d.ts","sourceRoot":"","sources":["../../../src/node/session/agent-session-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAwB,MAAM,EAAmB,MAAM,cAAc,CAAC;AAC7E,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,KAAK,mBAAmB,EAExB,KAAK,kBAAkB,EACvB,oBAAoB,EACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,YAAY,EAAqB,KAAK,gBAAgB,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAa,
|
|
1
|
+
{"version":3,"file":"agent-session-factory.d.ts","sourceRoot":"","sources":["../../../src/node/session/agent-session-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAwB,MAAM,EAAmB,MAAM,cAAc,CAAC;AAC7E,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,KAAK,mBAAmB,EAExB,KAAK,kBAAkB,EACvB,oBAAoB,EACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,YAAY,EAAqB,KAAK,gBAAgB,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAa,MAAM,OAAO,CAAC;AAG1I,qBACa,0BAA2B,YAAW,mBAAmB;IAElE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAGhD,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAI9D,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,cAAc,EAAE,CAAM;IAIrD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,CAAM;IAG3C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAE5B,MAAM,CAAC,cAAc,GAAE,mBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8B5E;IAED,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,mBAAmB,GAAG,kBAAkB,CAQ9E;IAED,UAAgB,oBAAoB,CAChC,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAChE,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAmCvD;IAED,qFAAqF;IACrF,SAAS,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,EAAE,CAwBlH;IAED,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzC;IAED,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAUrE;CACJ"}
|
|
@@ -16,6 +16,7 @@ const core_1 = require("@celljs/core");
|
|
|
16
16
|
const coding_agent_protocol_1 = require("../coding-agent-protocol");
|
|
17
17
|
const error_1 = require("../error");
|
|
18
18
|
const pi_1 = require("../pi");
|
|
19
|
+
const agent_tool_util_1 = require("./agent-tool-util");
|
|
19
20
|
let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
20
21
|
constructor() {
|
|
21
22
|
this.extensions = [];
|
|
@@ -47,7 +48,7 @@ let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
|
47
48
|
thinkingLevel: options.thinkingLevel,
|
|
48
49
|
tools: options.tools,
|
|
49
50
|
excludeTools: options.excludeTools,
|
|
50
|
-
customTools: ((_b = this.tools) !== null && _b !== void 0 ? _b : []).map(
|
|
51
|
+
customTools: ((_b = this.tools) !== null && _b !== void 0 ? _b : []).map(agent_tool_util_1.AgentToolUtil.toToolDefinition),
|
|
51
52
|
});
|
|
52
53
|
// Headless: extensions run without a UI, as in pi's RPC mode.
|
|
53
54
|
await session.bindExtensions({ mode: 'rpc' });
|
|
@@ -99,19 +100,6 @@ let DefaultAgentSessionFactory = class DefaultAgentSessionFactory {
|
|
|
99
100
|
}
|
|
100
101
|
return resourceLoader;
|
|
101
102
|
}
|
|
102
|
-
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
103
|
-
toToolDefinition(tool) {
|
|
104
|
-
var _a;
|
|
105
|
-
return {
|
|
106
|
-
name: tool.name,
|
|
107
|
-
label: tool.label,
|
|
108
|
-
description: tool.description,
|
|
109
|
-
parameters: tool.parameters,
|
|
110
|
-
executionMode: tool.executionMode,
|
|
111
|
-
prepareArguments: (_a = tool.prepareArguments) === null || _a === void 0 ? void 0 : _a.bind(tool),
|
|
112
|
-
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
103
|
/** The extensions the pi CLI loads by default, as `ai.codingAgent` turns them on. */
|
|
116
104
|
builtinExtensions(sdk, options) {
|
|
117
105
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-factory.js","sourceRoot":"","sources":["../../../src/node/session/agent-session-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoC;AACpC,+CAA6C;AAC7C,uCAA6E;AAC7E,oEAOkC;AAClC,oCAAwE;AACxE,
|
|
1
|
+
{"version":3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+BAAuB,CAC7B,GAAG,EACH,YAAY,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CACxE,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;;AAhJsB;IADlB,IAAA,YAAK,EAAC,4CAAoB,CAAC;;2DACoB;AAG7B;IADlB,IAAA,gBAAS,EAAC,4CAAoB,CAAC;;wEAC8B;AAI3C;IAFlB,IAAA,gBAAS,EAAC,sCAAc,CAAC;IACzB,IAAA,eAAQ,GAAE;;8DAC0C;AAIlC;IAFlB,IAAA,gBAAS,EAAC,oBAAS,CAAC;IACpB,IAAA,eAAQ,GAAE;;yDACgC;AAGxB;IADlB,IAAA,gBAAS,EAAC,aAAM,CAAC;;0DACgB;qCAhBzB,0BAA0B;IADtC,IAAA,gBAAS,EAAC,2CAAmB,CAAC;GAClB,0BAA0B,CAkJtC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentTool } from '@celljs/ai-agent';
|
|
2
|
+
import type { ToolDefinition } from '../pi';
|
|
3
|
+
export declare namespace AgentToolUtil {
|
|
4
|
+
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
5
|
+
function toToolDefinition(tool: AgentTool): ToolDefinition;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=agent-tool-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-util.d.ts","sourceRoot":"","sources":["../../../src/node/session/agent-tool-util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,yBAAiB,aAAa,CAAC;IAC3B,sHAAsH;IACtH,SAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,CAUhE;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentToolUtil = void 0;
|
|
4
|
+
var AgentToolUtil;
|
|
5
|
+
(function (AgentToolUtil) {
|
|
6
|
+
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
7
|
+
function toToolDefinition(tool) {
|
|
8
|
+
var _a;
|
|
9
|
+
return {
|
|
10
|
+
name: tool.name,
|
|
11
|
+
label: tool.label,
|
|
12
|
+
description: tool.description,
|
|
13
|
+
parameters: tool.parameters,
|
|
14
|
+
executionMode: tool.executionMode,
|
|
15
|
+
prepareArguments: (_a = tool.prepareArguments) === null || _a === void 0 ? void 0 : _a.bind(tool),
|
|
16
|
+
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
AgentToolUtil.toToolDefinition = toToolDefinition;
|
|
20
|
+
})(AgentToolUtil || (exports.AgentToolUtil = AgentToolUtil = {}));
|
|
21
|
+
//# sourceMappingURL=agent-tool-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-util.js","sourceRoot":"","sources":["../../../src/node/session/agent-tool-util.ts"],"names":[],"mappings":";;;AAGA,IAAiB,aAAa,CAa7B;AAbD,WAAiB,aAAa;IAC1B,sHAAsH;IACtH,SAAgB,gBAAgB,CAAC,IAAe;;QAC5C,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,MAAA,IAAI,CAAC,gBAAgB,0CAAE,IAAI,CAAC,IAAI,CAAC;YACnD,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAa,EAAE,MAAM,EAAE,QAAe,CAAC;SACpG,CAAC;IACxB,CAAC;IAVe,cAAA,gBAAgB,mBAU/B,CAAA;AACL,CAAC,EAbgB,aAAa,aAAb,aAAa,GAAb,aAAa,QAa7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./agent-session-factory"), exports);
|
|
18
18
|
__exportStar(require("./agent-session-manager"), exports);
|
|
19
|
+
__exportStar(require("./agent-tool-util"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/session/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,0DAAwC;AACxC,oDAAkC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ai-coding-agent",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Hosts pi coding agent sessions in Cell applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@celljs/ai-agent": "4.
|
|
37
|
-
"@celljs/ai-pi": "4.
|
|
38
|
-
"@celljs/core": "4.
|
|
36
|
+
"@celljs/ai-agent": "4.5.0",
|
|
37
|
+
"@celljs/ai-pi": "4.5.0",
|
|
38
|
+
"@celljs/core": "4.5.0",
|
|
39
39
|
"@earendil-works/pi-ai": "^1.5.0",
|
|
40
40
|
"@earendil-works/pi-coding-agent": "^1.5.0"
|
|
41
41
|
},
|
package/src/node/pi/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from 'bun:test';
|
|
2
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { PiBundleUtil } from './pi-bundle-util';
|
|
7
|
+
|
|
8
|
+
describe('PiBundleUtil', () => {
|
|
9
|
+
const bun = process.versions.bun;
|
|
10
|
+
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
Object.assign(process.versions, { bun });
|
|
14
|
+
if (packageDir === undefined) {
|
|
15
|
+
delete process.env.PI_PACKAGE_DIR;
|
|
16
|
+
} else {
|
|
17
|
+
process.env.PI_PACKAGE_DIR = packageDir;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function onNode(): void {
|
|
22
|
+
// process.versions is writable in Bun; the check is all specifier() looks at.
|
|
23
|
+
Object.assign(process.versions, { bun: undefined });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
it('loads the bundle in the package directory pi is told about first', () => {
|
|
27
|
+
onNode();
|
|
28
|
+
const dir = mkdtempSync(join(tmpdir(), 'pi-package-'));
|
|
29
|
+
mkdirSync(join(dir, 'dist/bundle'), { recursive: true });
|
|
30
|
+
writeFileSync(join(dir, 'dist/bundle/index.js'), '');
|
|
31
|
+
process.env.PI_PACKAGE_DIR = dir;
|
|
32
|
+
expect(PiBundleUtil.specifier()).toBe(pathToFileURL(join(dir, 'dist/bundle/index.js')).href);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('loads the installed bundle when that directory has none', () => {
|
|
36
|
+
onNode();
|
|
37
|
+
process.env.PI_PACKAGE_DIR = mkdtempSync(join(tmpdir(), 'pi-package-'));
|
|
38
|
+
expect(PiBundleUtil.specifier()).toEndWith('/@earendil-works/pi-coding-agent/dist/bundle/index.js');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('loads the package entry on Bun, which cannot run the bundle', () => {
|
|
42
|
+
expect(PiBundleUtil.specifier()).toBe('@earendil-works/pi-coding-agent');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
|
|
6
|
+
export namespace PiBundleUtil {
|
|
7
|
+
const PACKAGE = '@earendil-works/pi-coding-agent';
|
|
8
|
+
const BUNDLE = 'dist/bundle/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* What to `import()` for pi. The package's main entry is its unbundled build; the bundle its own `pi`
|
|
12
|
+
* command runs has the same exports, starts about 6 times faster and takes 30 MB less. The package's
|
|
13
|
+
* `exports` do not list it, so it is found by path. This file imports nothing else, so that
|
|
14
|
+
* processes that never use Cell (the `ta` command) can load it without `@celljs/core`. On Bun the
|
|
15
|
+
* main entry it is: the bundle holds a copy of undici that only runs on Node.js.
|
|
16
|
+
*
|
|
17
|
+
* `PI_PACKAGE_DIR` tells pi where its package is; a bundle there comes first. A distribution of pi
|
|
18
|
+
* (ta) ships its own build of pi there.
|
|
19
|
+
*/
|
|
20
|
+
export function specifier(): string {
|
|
21
|
+
if (process.versions.bun) {
|
|
22
|
+
return PACKAGE;
|
|
23
|
+
}
|
|
24
|
+
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
25
|
+
if (packageDir && existsSync(join(packageDir, BUNDLE))) {
|
|
26
|
+
return pathToFileURL(join(packageDir, BUNDLE)).href;
|
|
27
|
+
}
|
|
28
|
+
for (const nodeModules of createRequire(__filename).resolve.paths(PACKAGE) ?? []) {
|
|
29
|
+
const bundle = join(nodeModules, PACKAGE, BUNDLE);
|
|
30
|
+
if (existsSync(bundle)) {
|
|
31
|
+
return pathToFileURL(bundle).href;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return PACKAGE;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CodingAgentError } from '../error';
|
|
2
|
+
import { PiBundleUtil } from './pi-bundle-util';
|
|
2
3
|
|
|
3
4
|
/** The module namespace of `@earendil-works/pi-coding-agent`. */
|
|
4
5
|
export type PiSdk = typeof import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' }});
|
|
@@ -12,7 +13,7 @@ export namespace PiSdkUtil {
|
|
|
12
13
|
*/
|
|
13
14
|
export function load(): Promise<PiSdk> {
|
|
14
15
|
if (!sdk) {
|
|
15
|
-
sdk = import(
|
|
16
|
+
sdk = (import(/* @vite-ignore */ PiBundleUtil.specifier()) as Promise<PiSdk>).catch(cause => {
|
|
16
17
|
sdk = undefined;
|
|
17
18
|
throw new CodingAgentError(
|
|
18
19
|
'Cannot load @earendil-works/pi-coding-agent. Install it next to @celljs/ai-coding-agent; it needs Node.js >= 22.19.0 or Bun.',
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
ModelRuntimeProvider,
|
|
11
11
|
} from '../coding-agent-protocol';
|
|
12
12
|
import { AgentExtensionError, AgentModelNotFoundError } from '../error';
|
|
13
|
-
import { type AgentSession, type ExtensionAPI, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk, PiSdkUtil
|
|
13
|
+
import { type AgentSession, type ExtensionAPI, type ExtensionFactory, type Model, type ModelRuntime, type PiSdk, PiSdkUtil } from '../pi';
|
|
14
|
+
import { AgentToolUtil } from './agent-tool-util';
|
|
14
15
|
|
|
15
16
|
@Component(AgentSessionFactory)
|
|
16
17
|
export class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
@@ -56,7 +57,7 @@ export class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
|
56
57
|
thinkingLevel: options.thinkingLevel,
|
|
57
58
|
tools: options.tools,
|
|
58
59
|
excludeTools: options.excludeTools,
|
|
59
|
-
customTools: (this.tools ?? []).map(
|
|
60
|
+
customTools: (this.tools ?? []).map(AgentToolUtil.toToolDefinition),
|
|
60
61
|
});
|
|
61
62
|
// Headless: extensions run without a UI, as in pi's RPC mode.
|
|
62
63
|
await session.bindExtensions({ mode: 'rpc' });
|
|
@@ -116,19 +117,6 @@ export class DefaultAgentSessionFactory implements AgentSessionFactory {
|
|
|
116
117
|
return resourceLoader;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
120
|
-
protected toToolDefinition(tool: AgentTool): ToolDefinition {
|
|
121
|
-
return {
|
|
122
|
-
name: tool.name,
|
|
123
|
-
label: tool.label,
|
|
124
|
-
description: tool.description,
|
|
125
|
-
parameters: tool.parameters,
|
|
126
|
-
executionMode: tool.executionMode,
|
|
127
|
-
prepareArguments: tool.prepareArguments?.bind(tool),
|
|
128
|
-
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params as any, signal, onUpdate as any),
|
|
129
|
-
} as ToolDefinition;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
120
|
/** The extensions the pi CLI loads by default, as `ai.codingAgent` turns them on. */
|
|
133
121
|
protected builtinExtensions(sdk: PiSdk, options: CodingAgentOptions): { name: string; factory: ExtensionFactory }[] {
|
|
134
122
|
const extensions: { name: string; factory: ExtensionFactory }[] = [];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AgentTool } from '@celljs/ai-agent';
|
|
2
|
+
import type { ToolDefinition } from '../pi';
|
|
3
|
+
|
|
4
|
+
export namespace AgentToolUtil {
|
|
5
|
+
/** An AgentTool component as a tool of pi coding agent: the same shape, plus the session context it does not need. */
|
|
6
|
+
export function toToolDefinition(tool: AgentTool): ToolDefinition {
|
|
7
|
+
return {
|
|
8
|
+
name: tool.name,
|
|
9
|
+
label: tool.label,
|
|
10
|
+
description: tool.description,
|
|
11
|
+
parameters: tool.parameters,
|
|
12
|
+
executionMode: tool.executionMode,
|
|
13
|
+
prepareArguments: tool.prepareArguments?.bind(tool),
|
|
14
|
+
execute: (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params as any, signal, onUpdate as any),
|
|
15
|
+
} as ToolDefinition;
|
|
16
|
+
}
|
|
17
|
+
}
|