@11agents/cli 0.1.1 → 0.1.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/LICENSE +21 -0
- package/bin/11agents.js +4 -1
- package/package.json +2 -2
- package/src/commands/runtime.js +8 -1
- package/src/daemon-process.js +29 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 11agents.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/11agents.js
CHANGED
|
@@ -7,7 +7,7 @@ import { pushArtifact, pushBatch, pushObservation } from '../src/commands/push.j
|
|
|
7
7
|
import { registerRuntime, scanRuntime, startRuntimeDaemon } from '../src/commands/runtime.js'
|
|
8
8
|
import { startBackgroundDaemon, statusBackgroundDaemon, stopBackgroundDaemon } from '../src/daemon-process.js'
|
|
9
9
|
import { getControlConfig } from '../src/client.js'
|
|
10
|
-
import { printStartupInfo } from '../src/info.js'
|
|
10
|
+
import { CLI_VERSION, printStartupInfo } from '../src/info.js'
|
|
11
11
|
import { validateTelemetryBatch } from '../src/schema.js'
|
|
12
12
|
|
|
13
13
|
function usage() {
|
|
@@ -65,9 +65,12 @@ async function main() {
|
|
|
65
65
|
const result = await startBackgroundDaemon({
|
|
66
66
|
argv,
|
|
67
67
|
scriptPath: fileURLToPath(import.meta.url),
|
|
68
|
+
version: CLI_VERSION,
|
|
68
69
|
})
|
|
69
70
|
if (result.alreadyRunning) {
|
|
70
71
|
console.log(`11agents daemon already running with pid ${result.pid}`)
|
|
72
|
+
} else if (result.restarted) {
|
|
73
|
+
console.log(`11agents daemon restarted pid ${result.previousPid} -> ${result.pid}`)
|
|
71
74
|
} else {
|
|
72
75
|
console.log(`11agents daemon started with pid ${result.pid}`)
|
|
73
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@11agents/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "11agents local runtime and telemetry CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/11Agents/11agents-ai/issues"
|
|
32
32
|
},
|
|
33
|
-
"license": "
|
|
33
|
+
"license": "MIT",
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
}
|
package/src/commands/runtime.js
CHANGED
|
@@ -204,6 +204,7 @@ async function runCodex({ task, prompt, flags = {}, deps }) {
|
|
|
204
204
|
'--ask-for-approval',
|
|
205
205
|
'never',
|
|
206
206
|
'exec',
|
|
207
|
+
'--skip-git-repo-check',
|
|
207
208
|
'--sandbox',
|
|
208
209
|
flag(flags, 'codex-sandbox', 'workspace-write'),
|
|
209
210
|
'-C',
|
|
@@ -216,12 +217,18 @@ async function runCodex({ task, prompt, flags = {}, deps }) {
|
|
|
216
217
|
if (model) args.splice(execIndex + 1, 0, '--model', model)
|
|
217
218
|
if (profile) args.splice(execIndex + 1, 0, '--profile', profile)
|
|
218
219
|
|
|
220
|
+
const commandLine = [codexBin, ...args].map(value => JSON.stringify(String(value))).join(' ')
|
|
221
|
+
deps.log(JSON.stringify({ running: 'codex exec', command: commandLine, workdir }, null, 2))
|
|
219
222
|
const result = await deps.runProcess(codexBin, args, { input: prompt, cwd: workdir })
|
|
220
223
|
const output = String(result.stdout || '').trim()
|
|
221
224
|
const error = String(result.stderr || '').trim()
|
|
222
225
|
if (result.code !== 0) {
|
|
226
|
+
const body = error || output || `codex exited with status ${result.code}`
|
|
227
|
+
const trustHint = body.includes('--skip-git-repo-check')
|
|
228
|
+
? '\n\nCodex was invoked with --skip-git-repo-check. If this message persists, the background daemon may still be running an older CLI; run `11agents daemon start --background` again or restart it.'
|
|
229
|
+
: ''
|
|
223
230
|
return {
|
|
224
|
-
comment:
|
|
231
|
+
comment: `${body}\n\nCodex command: ${commandLine}${trustHint}`,
|
|
225
232
|
status: 'failed',
|
|
226
233
|
}
|
|
227
234
|
}
|
package/src/daemon-process.js
CHANGED
|
@@ -9,6 +9,7 @@ export function backgroundPaths(homeDir = homedir()) {
|
|
|
9
9
|
return {
|
|
10
10
|
dir,
|
|
11
11
|
pidPath: join(dir, 'daemon.pid'),
|
|
12
|
+
metaPath: join(dir, 'daemon.json'),
|
|
12
13
|
logPath: join(dir, 'daemon.log'),
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -31,6 +32,15 @@ async function readPid(pidPath) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
async function readMeta(metaPath) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(await readFile(metaPath, 'utf-8'))
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error?.code === 'ENOENT') return null
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
function isRunning(pid, killFn = process.kill) {
|
|
35
45
|
if (!pid) return false
|
|
36
46
|
try {
|
|
@@ -46,13 +56,24 @@ export async function startBackgroundDaemon({
|
|
|
46
56
|
homeDir = homedir(),
|
|
47
57
|
nodePath = process.execPath,
|
|
48
58
|
scriptPath,
|
|
59
|
+
version = '',
|
|
49
60
|
spawnFn = spawn,
|
|
61
|
+
killFn = process.kill,
|
|
50
62
|
} = {}) {
|
|
51
63
|
const paths = backgroundPaths(homeDir)
|
|
52
64
|
await mkdir(paths.dir, { recursive: true })
|
|
53
65
|
const existingPid = await readPid(paths.pidPath)
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
let restarted = false
|
|
67
|
+
let previousPid = null
|
|
68
|
+
if (isRunning(existingPid, killFn)) {
|
|
69
|
+
const meta = await readMeta(paths.metaPath)
|
|
70
|
+
if (meta?.version === version && meta?.scriptPath === scriptPath) {
|
|
71
|
+
return { alreadyRunning: true, pid: existingPid, logPath: paths.logPath }
|
|
72
|
+
}
|
|
73
|
+
killFn(existingPid, 'SIGTERM')
|
|
74
|
+
previousPid = existingPid
|
|
75
|
+
restarted = true
|
|
76
|
+
await rm(paths.pidPath, { force: true })
|
|
56
77
|
}
|
|
57
78
|
|
|
58
79
|
const log = await open(paths.logPath, constants.O_CREAT | constants.O_APPEND | constants.O_WRONLY, 0o600)
|
|
@@ -67,8 +88,13 @@ export async function startBackgroundDaemon({
|
|
|
67
88
|
})
|
|
68
89
|
if (!child?.pid) throw new Error('failed to start daemon')
|
|
69
90
|
await writeFile(paths.pidPath, String(child.pid))
|
|
91
|
+
await writeFile(paths.metaPath, JSON.stringify({
|
|
92
|
+
version,
|
|
93
|
+
scriptPath,
|
|
94
|
+
startedAt: new Date().toISOString(),
|
|
95
|
+
}))
|
|
70
96
|
child.unref?.()
|
|
71
|
-
return { pid: child.pid, logPath: paths.logPath }
|
|
97
|
+
return { pid: child.pid, logPath: paths.logPath, restarted, previousPid }
|
|
72
98
|
} finally {
|
|
73
99
|
await log.close()
|
|
74
100
|
}
|