@easynet/agent-runtime 1.0.1
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/.github/workflows/ci.yml +80 -0
- package/.github/workflows/release.yml +82 -0
- package/.releaserc.cjs +26 -0
- package/dist/cli.d.ts +43 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +617 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +86 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +84 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +104 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +111 -0
- package/dist/context.js.map +1 -0
- package/dist/deep-agent.d.ts +29 -0
- package/dist/deep-agent.d.ts.map +1 -0
- package/dist/deep-agent.js +77 -0
- package/dist/deep-agent.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/malformed-tool-call-middleware.d.ts +8 -0
- package/dist/malformed-tool-call-middleware.d.ts.map +1 -0
- package/dist/malformed-tool-call-middleware.js +191 -0
- package/dist/malformed-tool-call-middleware.js.map +1 -0
- package/dist/react-agent.d.ts +38 -0
- package/dist/react-agent.d.ts.map +1 -0
- package/dist/react-agent.js +465 -0
- package/dist/react-agent.js.map +1 -0
- package/dist/sub-agent.d.ts +34 -0
- package/dist/sub-agent.d.ts.map +1 -0
- package/dist/sub-agent.js +53 -0
- package/dist/sub-agent.js.map +1 -0
- package/example/basic-usage.ts +49 -0
- package/package.json +53 -0
- package/src/cli.ts +745 -0
- package/src/config.ts +177 -0
- package/src/context.ts +247 -0
- package/src/deep-agent.ts +104 -0
- package/src/index.ts +53 -0
- package/src/malformed-tool-call-middleware.ts +239 -0
- package/src/markdown-it-terminal.d.ts +4 -0
- package/src/marked-terminal.d.ts +16 -0
- package/src/react-agent.ts +576 -0
- package/src/sub-agent.ts +82 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ['**']
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ['**']
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: Test & Build
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
timeout-minutes: 25
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '20'
|
|
26
|
+
cache: 'npm'
|
|
27
|
+
registry-url: 'https://registry.npmjs.org'
|
|
28
|
+
|
|
29
|
+
- name: Force npm registry to npmjs.org
|
|
30
|
+
run: |
|
|
31
|
+
touch .npmrc
|
|
32
|
+
grep -q '^registry=https://registry.npmjs.org' .npmrc || echo "registry=https://registry.npmjs.org/" >> .npmrc
|
|
33
|
+
grep -q '@easynet:registry=' .npmrc || echo "@easynet:registry=https://registry.npmjs.org/" >> .npmrc
|
|
34
|
+
grep -q '@wallee:registry=' .npmrc || echo "@wallee:registry=https://registry.npmjs.org/" >> .npmrc
|
|
35
|
+
|
|
36
|
+
- name: Use @easynet deps from npm (CI has no file:../)
|
|
37
|
+
run: |
|
|
38
|
+
node -e "
|
|
39
|
+
const fs = require('fs');
|
|
40
|
+
const pkgPath = 'package.json';
|
|
41
|
+
const p = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
42
|
+
let changed = false;
|
|
43
|
+
for (const section of ['dependencies', 'devDependencies']) {
|
|
44
|
+
if (!p[section]) continue;
|
|
45
|
+
for (const [name, v] of Object.entries(p[section])) {
|
|
46
|
+
if (name.startsWith('@easynet/') && typeof v === 'string' && v.startsWith('file:')) {
|
|
47
|
+
p[section][name] = 'latest';
|
|
48
|
+
changed = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (changed) fs.writeFileSync(pkgPath, JSON.stringify(p, null, 2) + '\n');
|
|
53
|
+
"
|
|
54
|
+
|
|
55
|
+
- name: Remove lockfile to avoid stale local/git refs
|
|
56
|
+
run: rm -f package-lock.json
|
|
57
|
+
|
|
58
|
+
- name: Install dependencies
|
|
59
|
+
env:
|
|
60
|
+
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/"
|
|
61
|
+
run: npm install --legacy-peer-deps
|
|
62
|
+
|
|
63
|
+
- name: Build
|
|
64
|
+
run: npm run build --if-present
|
|
65
|
+
|
|
66
|
+
- name: Typecheck
|
|
67
|
+
run: npm run typecheck --if-present
|
|
68
|
+
|
|
69
|
+
- name: Test
|
|
70
|
+
run: npm test --if-present
|
|
71
|
+
|
|
72
|
+
- name: Diagnostics (on failure)
|
|
73
|
+
if: failure()
|
|
74
|
+
run: |
|
|
75
|
+
echo "Node: $(node -v) | npm: $(npm -v)"
|
|
76
|
+
echo "--- .npmrc ---"
|
|
77
|
+
cat .npmrc 2>&1 || true
|
|
78
|
+
echo "--- npm config ---"
|
|
79
|
+
npm config list 2>&1 || true
|
|
80
|
+
npm ls --depth=0 2>&1 | head -50
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
name: Release
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
timeout-minutes: 30
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
|
|
28
|
+
- name: Setup Node.js
|
|
29
|
+
uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: '20'
|
|
32
|
+
cache: 'npm'
|
|
33
|
+
registry-url: 'https://registry.npmjs.org'
|
|
34
|
+
|
|
35
|
+
- name: Force npm registry to npmjs.org
|
|
36
|
+
run: |
|
|
37
|
+
touch .npmrc
|
|
38
|
+
grep -q '^registry=https://registry.npmjs.org' .npmrc || echo "registry=https://registry.npmjs.org/" >> .npmrc
|
|
39
|
+
grep -q '@easynet:registry=' .npmrc || echo "@easynet:registry=https://registry.npmjs.org/" >> .npmrc
|
|
40
|
+
grep -q '@wallee:registry=' .npmrc || echo "@wallee:registry=https://registry.npmjs.org/" >> .npmrc
|
|
41
|
+
|
|
42
|
+
- name: Use @easynet deps from npm (CI has no file:../)
|
|
43
|
+
run: |
|
|
44
|
+
node -e "
|
|
45
|
+
const fs = require('fs');
|
|
46
|
+
const pkgPath = 'package.json';
|
|
47
|
+
const p = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
48
|
+
let changed = false;
|
|
49
|
+
for (const section of ['dependencies', 'devDependencies']) {
|
|
50
|
+
if (!p[section]) continue;
|
|
51
|
+
for (const [name, v] of Object.entries(p[section])) {
|
|
52
|
+
if (name.startsWith('@easynet/') && typeof v === 'string' && v.startsWith('file:')) {
|
|
53
|
+
p[section][name] = 'latest';
|
|
54
|
+
changed = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (changed) fs.writeFileSync(pkgPath, JSON.stringify(p, null, 2) + '\n');
|
|
59
|
+
"
|
|
60
|
+
|
|
61
|
+
- name: Remove lockfile to avoid stale local/git refs
|
|
62
|
+
run: rm -f package-lock.json
|
|
63
|
+
|
|
64
|
+
- name: Install dependencies
|
|
65
|
+
env:
|
|
66
|
+
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/"
|
|
67
|
+
run: npm install --legacy-peer-deps
|
|
68
|
+
|
|
69
|
+
- name: Build
|
|
70
|
+
run: npm run build --if-present
|
|
71
|
+
|
|
72
|
+
- name: Typecheck
|
|
73
|
+
run: npm run typecheck --if-present
|
|
74
|
+
|
|
75
|
+
- name: Test
|
|
76
|
+
run: npm test --if-present
|
|
77
|
+
|
|
78
|
+
- name: Release
|
|
79
|
+
env:
|
|
80
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
81
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
82
|
+
run: npx semantic-release
|
package/.releaserc.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @type {import('semantic-release').GlobalConfig} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
branches: ['master'],
|
|
4
|
+
plugins: [
|
|
5
|
+
[
|
|
6
|
+
'@semantic-release/commit-analyzer',
|
|
7
|
+
{
|
|
8
|
+
releaseRules: [
|
|
9
|
+
{ type: 'feat', release: 'patch' },
|
|
10
|
+
{ type: 'fix', release: 'patch' },
|
|
11
|
+
{ type: 'docs', release: 'patch' },
|
|
12
|
+
{ type: 'chore', release: 'patch' },
|
|
13
|
+
{ type: 'refactor', release: 'patch' },
|
|
14
|
+
{ type: 'perf', release: 'patch' },
|
|
15
|
+
{ type: 'test', release: 'patch' },
|
|
16
|
+
{ type: 'ci', release: 'patch' },
|
|
17
|
+
{ type: 'build', release: 'patch' },
|
|
18
|
+
{ message: '*', release: 'patch' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
'@semantic-release/release-notes-generator',
|
|
23
|
+
'@semantic-release/npm',
|
|
24
|
+
'@semantic-release/git',
|
|
25
|
+
],
|
|
26
|
+
};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AgentEventListener } from "@easynet/agent-common";
|
|
2
|
+
import type { BotContext } from "./context.js";
|
|
3
|
+
export interface AppCliUiOptions {
|
|
4
|
+
/** Prompt/section label for user. Default: current OS user (username(uid)). */
|
|
5
|
+
userLabel?: string;
|
|
6
|
+
/** Prompt/section label for assistant. Default: agent kind (ReAct/Deep). */
|
|
7
|
+
assistantLabel?: string;
|
|
8
|
+
/** Enable ANSI colors in interactive output. Default: true when TTY and NO_COLOR is not set. */
|
|
9
|
+
useColor?: boolean;
|
|
10
|
+
/** Render assistant output as terminal-friendly markdown. Default: true. */
|
|
11
|
+
renderMarkdown?: boolean;
|
|
12
|
+
/** Echo the user question in the response section. Default: true. */
|
|
13
|
+
echoUserQuestion?: boolean;
|
|
14
|
+
/** Startup loading line. Set false to suppress. */
|
|
15
|
+
loadingText?: string | false;
|
|
16
|
+
/** Show animated loading progress while creating bot context. */
|
|
17
|
+
loadingSpinner?: boolean;
|
|
18
|
+
/** Startup ready line. Set false to suppress. */
|
|
19
|
+
readyText?: string | false;
|
|
20
|
+
/** Interactive intro line before prompt. Set false to suppress. */
|
|
21
|
+
interactiveIntro?: string | false;
|
|
22
|
+
/** Show animated spinner while a user request is being processed. */
|
|
23
|
+
processingSpinner?: boolean;
|
|
24
|
+
/** Spinner label shown while processing. Set false to suppress label/spinner. */
|
|
25
|
+
processingText?: string | false;
|
|
26
|
+
}
|
|
27
|
+
export interface AppCliOptions {
|
|
28
|
+
appName: string;
|
|
29
|
+
createBotContext: () => Promise<BotContext>;
|
|
30
|
+
/** Extra interactive commands, e.g. { "list tools": (ctx) => ... } */
|
|
31
|
+
interactiveCommands?: Record<string, (ctx: BotContext) => void | Promise<void>>;
|
|
32
|
+
/** Extra event listener(s) for structured runtime logs. */
|
|
33
|
+
eventListener?: AgentEventListener | AgentEventListener[];
|
|
34
|
+
/** Called after context is ready, before the REPL starts. Failures are logged but do not crash. */
|
|
35
|
+
onReady?: (ctx: BotContext) => void | Promise<void>;
|
|
36
|
+
/** Called during shutdown (exit/signal). Should be synchronous and fast. */
|
|
37
|
+
onShutdown?: (ctx: BotContext) => void;
|
|
38
|
+
/** Interactive UI style options. */
|
|
39
|
+
ui?: AppCliUiOptions;
|
|
40
|
+
}
|
|
41
|
+
export declare function createStructuredRunEventListener(writer?: (line: string) => void): AgentEventListener;
|
|
42
|
+
export declare function runAppCli(options: AppCliOptions): void;
|
|
43
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO/C,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAClC,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAChF,2DAA2D;IAC3D,aAAa,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;IAC1D,mGAAmG;IACnG,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,4EAA4E;IAC5E,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,oCAAoC;IACpC,EAAE,CAAC,EAAE,eAAe,CAAC;CACtB;AAidD,wBAAgB,gCAAgC,CAC9C,MAAM,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAoB,GAC7C,kBAAkB,CAkIpB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAoFtD"}
|