agentlas 0.4.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/LICENSE +201 -0
- package/README.md +107 -0
- package/bin/agentlas.cjs +176 -0
- package/engine/ENGINE_META.json +8 -0
- package/engine/agentlas-api-agent.cjs +451 -0
- package/engine/agentlas-banner.cjs +108 -0
- package/engine/agentlas-capabilities.cjs +72 -0
- package/engine/agentlas-cloud-runtime.cjs +199 -0
- package/engine/agentlas-composer.cjs +256 -0
- package/engine/agentlas-config.cjs +29 -0
- package/engine/agentlas-doctor.cjs +173 -0
- package/engine/agentlas-i18n.cjs +317 -0
- package/engine/agentlas-input.cjs +437 -0
- package/engine/agentlas-native-host.cjs +612 -0
- package/engine/agentlas-onboard.cjs +71 -0
- package/engine/agentlas-parity.cjs +994 -0
- package/engine/agentlas-repl.cjs +1258 -0
- package/engine/agentlas-style.cjs +100 -0
- package/engine/agentlas-tools.cjs +196 -0
- package/engine/agentlas-ui.cjs +266 -0
- package/engine/agentlas.cjs +7503 -0
- package/engine/architecture.data.json +139 -0
- package/engine/bootstrap-schema.sql +568 -0
- package/install.ps1 +26 -0
- package/install.sh +53 -0
- package/package.json +49 -0
- package/scripts/gen-bootstrap-schema.sh +23 -0
- package/test/smoke.sh +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend, and
|
|
172
|
+
hold each Contributor harmless for any liability incurred by, or
|
|
173
|
+
claims asserted against, such Contributor by reason of your accepting
|
|
174
|
+
any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Agentlas
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# agentlas
|
|
2
|
+
|
|
3
|
+
**The Agentlas agent terminal.** Chat with your installed AI agents and teams
|
|
4
|
+
from the terminal — Claude Code style. Standalone: no desktop app required.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install -g agentlas
|
|
8
|
+
agentlas
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Type a task and it auto-routes to the right agent. Your model, your choice:
|
|
12
|
+
Claude Code / Codex / Gemini CLI subscriptions or BYOK API keys.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
**Agentlas 터미널 CLI** — Claude Code(`claude`), Codex(`codex`)처럼
|
|
17
|
+
`npm install` 하나로 깔리고, `agentlas` 하나로 도는 독립 에이전트 터미널.
|
|
18
|
+
**데스크탑 앱이 없어도 동작한다.**
|
|
19
|
+
|
|
20
|
+
- 엔진(대화형 REPL·에이전트 라우팅·팀 실행·클라우드 설치·자격증명 관리)이
|
|
21
|
+
패키지에 통째로 번들되어 있다.
|
|
22
|
+
- 첫 실행 시 앱과 동일한 SQLite 스키마를 직접 부트스트랩하고 빌트인
|
|
23
|
+
에이전트(오케스트레이터·PM 소울·메모리 큐레이터 등)를 시드한다.
|
|
24
|
+
- 데스크탑 앱이 설치돼 있으면 같은 데이터(에이전트·채팅·키체인)를 자동
|
|
25
|
+
공유한다 — 앱에서 설치한 에이전트가 터미널에 바로 보인다.
|
|
26
|
+
|
|
27
|
+
## 설치
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install -g agentlas
|
|
31
|
+
# 또는 이 폴더에서: npm install -g .
|
|
32
|
+
# 또는: sh install.sh # ~/.local/bin/agentlas 심링크 (sudo 불필요)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Windows(미검증): `powershell -ExecutionPolicy Bypass -File install.ps1`
|
|
36
|
+
|
|
37
|
+
요구사항: Node 20+ (better-sqlite3 빌드 실패 시 Node 22+의 `node:sqlite` 폴백).
|
|
38
|
+
에이전트 실행에는 claude / codex / gemini 중 하나의 CLI가 필요하다(BYOK API 키도 가능).
|
|
39
|
+
|
|
40
|
+
## 사용
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
agentlas # 대화형 TUI (온보딩 → 에이전트 피커 → 스트리밍 REPL)
|
|
44
|
+
agentlas list # 설치된 에이전트/회사 + 활성 런타임
|
|
45
|
+
agentlas <agent> # 해당 에이전트와 대화형 세션
|
|
46
|
+
agentlas run <agent> "프롬프트" # 1회 실행 (prompt 없으면 stdin)
|
|
47
|
+
agentlas firm <firm> "프롬프트" # 회사(팀) 실행
|
|
48
|
+
agentlas cd <agent> # 에이전트 폴더 경로 → cd "$(agentlas cd seo)" && claude
|
|
49
|
+
agentlas import <폴더> # 로컬 에이전트/팀 임포트
|
|
50
|
+
agentlas storm "목표" # Stormbreaker 파이프라인 (라우팅→검증→실행) [--research]
|
|
51
|
+
agentlas swarm "목표" # emergent 에이전트 스웜 (병렬+블랙보드+종합) [--parallel N]
|
|
52
|
+
agentlas login | logout | whoami # Agentlas Cloud 로그인 (브라우저 플로우)
|
|
53
|
+
agentlas automation list|add|on|off|remove|runs # 자동화 등록/관리
|
|
54
|
+
agentlas automation run <id> # 자동화 지금 1회 실행
|
|
55
|
+
agentlas automation daemon # 상주 실행기 — 앱 없이 예약 자동화 실행 (앱과 리스 공유)
|
|
56
|
+
agentlas cloud search "찾는 일" # 마켓플레이스 검색 (로그인 불필요)
|
|
57
|
+
agentlas cloud install <slug> # 마켓플레이스에서 에이전트 설치
|
|
58
|
+
agentlas usage # 로컬 사용 현황 (실행/메시지/자동화)
|
|
59
|
+
agentlas telegram # 텔레그램 바인딩 현황 (읽기 전용)
|
|
60
|
+
agentlas creds / env # 자격증명 · env
|
|
61
|
+
agentlas multimodal # 이미지/영상/음성 provider
|
|
62
|
+
agentlas doctor # 런타임/데이터 점검
|
|
63
|
+
agentlas setup # 온보딩(언어→런타임→권한) 다시 실행
|
|
64
|
+
agentlas update # Desktop 최신 릴리스 확인/설치
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
공통 옵션: `--runtime claude-code|codex|gemini` · `--permission read|write|full`
|
|
68
|
+
|
|
69
|
+
## 동작 방식
|
|
70
|
+
|
|
71
|
+
런처(`bin/agentlas.cjs`)가 이 패키지의 `engine/`(정본)을 시스템 Node로 실행한다 —
|
|
72
|
+
데스크탑 앱과 완전히 독립이며, 앱이 설치돼 있으면 같은 userData(SQLite)를 써서
|
|
73
|
+
데이터만 자연스럽게 공유된다. `engine/ENGINE_META.json`에 최초 임포트 출처가 기록돼 있다.
|
|
74
|
+
|
|
75
|
+
SQLite는 `better-sqlite3`(optionalDependency, npm이 네이티브 빌드) → 실패 시
|
|
76
|
+
Node 22+ `node:sqlite` 폴백. 데이터 폴더는 앱과 동일한 userData
|
|
77
|
+
(macOS `~/Library/Application Support/Agentlas`)이며 `AGENTLAS_USER_DATA_DIR`로
|
|
78
|
+
바꿀 수 있다.
|
|
79
|
+
|
|
80
|
+
### 개발
|
|
81
|
+
|
|
82
|
+
엔진 소스는 `engine/*.cjs` — 여기가 정본이므로 직접 수정한다.
|
|
83
|
+
첫 실행용 스키마가 데스크탑 DB 마이그레이션과 어긋나면 재생성:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
sh scripts/gen-bootstrap-schema.sh [db-path] # engine/bootstrap-schema.sql 재생성
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 진단
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
agentlas --where # 엔진/DB 해석 결과 JSON
|
|
93
|
+
sh test/smoke.sh # where/version/list/doctor + 신선 환경 첫 실행
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 제거
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm uninstall -g agentlas # npm 설치 시
|
|
100
|
+
rm ~/.local/bin/agentlas # install.sh 설치 시
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
Apache-2.0 — engine sources are vendored from the public
|
|
106
|
+
[agentlas-ai/agentlas-desktop](https://github.com/agentlas-ai/agentlas-desktop) repo
|
|
107
|
+
(see `engine/ENGINE_META.json` for the exact version/commit).
|
package/bin/agentlas.cjs
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* agentlas — Agentlas를 터미널에서 쓰는 독립 CLI (Claude Code 방식).
|
|
4
|
+
*
|
|
5
|
+
* `npm install -g agentlas` 후 `agentlas` 하나로 완결된다. 데스크탑 앱은 필요 없다:
|
|
6
|
+
* 엔진(engine/agentlas.cjs — REPL·라우팅·클라우드·자격증명 포함 전체 터미널
|
|
7
|
+
* 클라이언트)이 이 패키지에 들어 있고(정본), 첫 실행 시 앱과 동일한 SQLite 스키마를
|
|
8
|
+
* 직접 부트스트랩한 뒤 빌트인 에이전트를 시드한다. 데스크탑 앱이 설치돼 있으면
|
|
9
|
+
* 같은 userData(SQLite)를 자동으로 공유한다 — 별도 설정 없이 데이터가 한 몸이다.
|
|
10
|
+
*
|
|
11
|
+
* SQLite: better-sqlite3(optionalDependency, npm이 빌드해주면 네이티브) →
|
|
12
|
+
* 실패 시 Node 22+의 node:sqlite 폴백.
|
|
13
|
+
*
|
|
14
|
+
* env 오버라이드:
|
|
15
|
+
* AGENTLAS_USER_DATA_DIR 데이터 폴더 (기본: 앱과 동일한 userData)
|
|
16
|
+
*
|
|
17
|
+
* 런처 자체 명령: `agentlas --where` → 해석 결과 JSON 출력 후 종료.
|
|
18
|
+
*/
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
const fs = require("node:fs");
|
|
22
|
+
const os = require("node:os");
|
|
23
|
+
const path = require("node:path");
|
|
24
|
+
const { spawn } = require("node:child_process");
|
|
25
|
+
|
|
26
|
+
const REAL_SELF = (() => {
|
|
27
|
+
try { return fs.realpathSync(__filename); } catch { return __filename; }
|
|
28
|
+
})();
|
|
29
|
+
const PKG_ROOT = path.dirname(path.dirname(REAL_SELF));
|
|
30
|
+
const ENGINE = path.join(PKG_ROOT, "engine", "agentlas.cjs");
|
|
31
|
+
|
|
32
|
+
function exists(p) {
|
|
33
|
+
try { fs.accessSync(p); return true; } catch { return false; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ── userData / DB 경로 (engine/agentlas.cjs의 userDataDir와 동일 규칙) ──
|
|
37
|
+
function userDataDir() {
|
|
38
|
+
const override = process.env.AGENTLAS_USER_DATA_DIR;
|
|
39
|
+
if (override) return override;
|
|
40
|
+
const home = os.homedir();
|
|
41
|
+
if (process.platform === "darwin") return path.join(home, "Library", "Application Support", "Agentlas");
|
|
42
|
+
if (process.platform === "win32") return path.join(process.env.APPDATA || path.join(home, "AppData", "Roaming"), "Agentlas");
|
|
43
|
+
return path.join(process.env.XDG_CONFIG_HOME || path.join(home, ".config"), "Agentlas");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function dbPath() {
|
|
47
|
+
return path.join(userDataDir(), "agentlas.sqlite");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ── SQLite 로더 (부트스트랩용): better-sqlite3 → node:sqlite ──
|
|
51
|
+
// require.resolve가 아니라 실제 로드로 판별한다 — ABI가 깨진 better-sqlite3나
|
|
52
|
+
// node:sqlite가 아직 없는/플래그가 필요한 Node(≤22.4 등)를 정확히 걸러낸다.
|
|
53
|
+
function probeSqliteDriver() {
|
|
54
|
+
try { require("better-sqlite3"); return "better-sqlite3"; } catch { /* absent or ABI-broken */ }
|
|
55
|
+
try {
|
|
56
|
+
const { DatabaseSync } = require("node:sqlite");
|
|
57
|
+
if (DatabaseSync) return "node:sqlite";
|
|
58
|
+
} catch { /* not available without a flag on this Node */ }
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function openSqlite(p) {
|
|
63
|
+
try {
|
|
64
|
+
const Database = require("better-sqlite3");
|
|
65
|
+
const db = new Database(p);
|
|
66
|
+
return { exec: (sql) => db.exec(sql), close: () => db.close(), driver: "better-sqlite3" };
|
|
67
|
+
} catch { /* optional dep 미설치/ABI 불일치 */ }
|
|
68
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
69
|
+
if (major < 22) {
|
|
70
|
+
throw new Error(`Node ${process.version} — better-sqlite3가 없으면 Node 22+ (node:sqlite)가 필요합니다.`);
|
|
71
|
+
}
|
|
72
|
+
const { DatabaseSync } = require("node:sqlite");
|
|
73
|
+
const db = new DatabaseSync(p);
|
|
74
|
+
return { exec: (sql) => db.exec(sql), close: () => db.close(), driver: "node:sqlite" };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 첫 실행 부트스트랩: DB가 없으면 앱과 동일한 스키마를 만든다.
|
|
78
|
+
// (엔진의 openDb는 파일이 없으면 하드 실패하므로, 여기서 미리 만들어 준다.
|
|
79
|
+
// 스키마가 생기면 엔진의 seedBuiltins가 빌트인 에이전트를 채운다.)
|
|
80
|
+
function bootstrapDbIfMissing() {
|
|
81
|
+
const p = dbPath();
|
|
82
|
+
if (exists(p)) return { created: false, path: p };
|
|
83
|
+
const schemaFile = path.join(PKG_ROOT, "engine", "bootstrap-schema.sql");
|
|
84
|
+
if (!exists(schemaFile)) {
|
|
85
|
+
throw new Error(`부트스트랩 스키마가 없습니다: ${schemaFile}`);
|
|
86
|
+
}
|
|
87
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
88
|
+
const sql = fs.readFileSync(schemaFile, "utf8");
|
|
89
|
+
const db = openSqlite(p);
|
|
90
|
+
try {
|
|
91
|
+
db.exec(sql);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
db.close();
|
|
94
|
+
try { fs.rmSync(p); } catch { /* leave partial for inspection */ }
|
|
95
|
+
throw new Error(`DB 부트스트랩 실패: ${e.message}`);
|
|
96
|
+
}
|
|
97
|
+
db.close();
|
|
98
|
+
return { created: true, path: p };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function main() {
|
|
102
|
+
const args = process.argv.slice(2);
|
|
103
|
+
const sqliteDriver = probeSqliteDriver();
|
|
104
|
+
const engineFound = exists(ENGINE);
|
|
105
|
+
|
|
106
|
+
let error = null;
|
|
107
|
+
if (!engineFound) {
|
|
108
|
+
error = "엔진이 없습니다 (engine/agentlas.cjs). 재설치: npm i -g agentlas";
|
|
109
|
+
} else if (!sqliteDriver) {
|
|
110
|
+
error = `Node ${process.version} — SQLite 드라이버가 없습니다. Node 22.5+ 로 올리거나 'npm i -g agentlas'로 재설치(better-sqlite3 빌드)하세요.`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (args[0] === "--where" || args[0] === "terminal-where") {
|
|
114
|
+
process.stdout.write(JSON.stringify({
|
|
115
|
+
launcher: REAL_SELF,
|
|
116
|
+
packageRoot: PKG_ROOT,
|
|
117
|
+
engine: ENGINE,
|
|
118
|
+
engineFound,
|
|
119
|
+
db: dbPath(),
|
|
120
|
+
dbExists: exists(dbPath()),
|
|
121
|
+
sqliteDriver,
|
|
122
|
+
node: process.version,
|
|
123
|
+
error,
|
|
124
|
+
}, null, 2) + "\n");
|
|
125
|
+
process.exit(error ? 1 : 0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (error) {
|
|
129
|
+
process.stderr.write(error + "\n");
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const boot = bootstrapDbIfMissing();
|
|
135
|
+
if (boot.created) {
|
|
136
|
+
process.stderr.write(`첫 실행: Agentlas 데이터 초기화 완료 (${boot.path})\n`);
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
process.stderr.write(`${e.message}\n`);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const child = spawn(process.execPath, [ENGINE, ...args], { stdio: "inherit" });
|
|
144
|
+
|
|
145
|
+
// 시그널 처리:
|
|
146
|
+
// - 터미널 Ctrl-C(SIGINT)는 포그라운드 프로세스 그룹으로 자식(REPL)에게 이미 전달된다.
|
|
147
|
+
// 런처가 한 번 더 전달하면 REPL의 "Ctrl-C 두 번이면 종료"가 오작동하므로 전달하지 않는다.
|
|
148
|
+
// - PID로 직접 온 SIGTERM/SIGHUP(kill·프로세스 매니저·timeout(1))은 자식에게 전달한다.
|
|
149
|
+
try { process.on("SIGINT", () => { /* group delivery already reached the child */ }); } catch { /* ignore */ }
|
|
150
|
+
for (const sig of ["SIGTERM", "SIGHUP"]) {
|
|
151
|
+
try {
|
|
152
|
+
process.on(sig, () => {
|
|
153
|
+
try { child.kill(sig); } catch { /* already dead */ }
|
|
154
|
+
});
|
|
155
|
+
} catch { /* win32 SIGHUP 등 */ }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
child.on("error", (err) => {
|
|
159
|
+
process.stderr.write(`Agentlas 엔진 실행 실패: ${err.message}\n`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
});
|
|
162
|
+
child.on("exit", (code, signal) => {
|
|
163
|
+
if (signal) {
|
|
164
|
+
// 자식의 시그널 종료를 그대로 전파 — 자체 핸들러를 걷어내야 재raise가 먹는다.
|
|
165
|
+
try {
|
|
166
|
+
process.removeAllListeners(signal);
|
|
167
|
+
process.kill(process.pid, signal);
|
|
168
|
+
} catch { /* fall through to numeric exit */ }
|
|
169
|
+
const num = os.constants.signals[signal];
|
|
170
|
+
process.exit(num ? 128 + num : 1);
|
|
171
|
+
}
|
|
172
|
+
process.exit(code == null ? 0 : code);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
main();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"canonical": true,
|
|
3
|
+
"note": "이 engine/ 이 엔진 소스의 정본(canonical home)입니다. 데스크탑 앱에서 벤더링하지 않습니다 — 여기서 직접 유지보수합니다.",
|
|
4
|
+
"importedFrom": "agentlas-ai/agentlas-desktop/cli",
|
|
5
|
+
"importedAtDesktopVersion": "0.7.18",
|
|
6
|
+
"importedAtCommit": "bcfe0df",
|
|
7
|
+
"independentSince": "2026-07-07"
|
|
8
|
+
}
|