durebak 0.0.0-stage → 0.1.0-alpha.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 +202 -0
- package/README.md +89 -2
- package/SECURITY.md +41 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +141 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.js +58 -0
- package/dist/content.d.ts +9 -0
- package/dist/content.js +28 -0
- package/dist/database.d.ts +3 -0
- package/dist/database.js +35 -0
- package/dist/doctor.d.ts +20 -0
- package/dist/doctor.js +34 -0
- package/dist/domain.d.ts +73 -0
- package/dist/domain.js +16 -0
- package/dist/harnesses/claude-code.d.ts +2 -0
- package/dist/harnesses/claude-code.js +4 -0
- package/dist/harnesses/codex.d.ts +2 -0
- package/dist/harnesses/codex.js +4 -0
- package/dist/harnesses/opencode.d.ts +2 -0
- package/dist/harnesses/opencode.js +4 -0
- package/dist/harnesses/registry.d.ts +4 -0
- package/dist/harnesses/registry.js +27 -0
- package/dist/harnesses/types.d.ts +13 -0
- package/dist/harnesses/types.js +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +48 -0
- package/dist/migrations.d.ts +3 -0
- package/dist/migrations.js +78 -0
- package/dist/paths.d.ts +9 -0
- package/dist/paths.js +42 -0
- package/dist/queue-policy.d.ts +23 -0
- package/dist/queue-policy.js +24 -0
- package/dist/records.d.ts +5 -0
- package/dist/records.js +16 -0
- package/dist/runtime.d.ts +97 -0
- package/dist/runtime.js +245 -0
- package/dist/setup.d.ts +7 -0
- package/dist/setup.js +23 -0
- package/dist/store.d.ts +185 -0
- package/dist/store.js +298 -0
- package/dist/transactions.d.ts +2 -0
- package/dist/transactions.js +14 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +6 -0
- package/docs/USAGE.md +209 -0
- package/package.json +54 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 두레박 · Durebak
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**서로 다른 코딩 에이전트 세션을 잇는 로컬 협업 도구.**
|
|
4
|
+
|
|
5
|
+
Local, durable collaboration between coding-agent sessions. Experimental alpha for Claude Code, Codex and OpenCode integrations.
|
|
6
|
+
|
|
7
|
+
두레박은 같은 컴퓨터의 코딩 에이전트 세션이 메시지·작업·결과를 주고받는 로컬 협업 런타임입니다. 각 세션은 자기 호스트와 맥락을 유지하고, CLI 또는 MCP로 참여합니다.
|
|
8
|
+
|
|
9
|
+
**현재 버전: 0.1.0-alpha.2, Cooperative 모드.** SQLite 저장소, 인증된 loopback 서버, CLI, MCP stdio bridge가 구현되어 있습니다. 실제 MCP 프로세스 간 통신을 테스트했으며, 호스트별 실제 시험 결과와 제약은 [호스트 테스트](docs/HOST-TESTING.md)에 기록합니다. 자동 세션 실행·깨우기와 반복 작업 스케줄러는 후속 기능입니다.
|
|
10
|
+
|
|
11
|
+
## 시작하기
|
|
12
|
+
|
|
13
|
+
Node.js 24 이상과 npm이 필요합니다.
|
|
14
|
+
|
|
15
|
+
`npx`로 alpha 버전을 실행할 수 있습니다.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx --yes durebak@alpha --help
|
|
19
|
+
npx --yes durebak@alpha serve
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
재현 가능한 설치에는 `durebak@0.1.0-alpha.2`처럼 정확한 버전을 지정하세요. 서버는 foreground에서 실행하며 Ctrl-C로 종료합니다.
|
|
23
|
+
|
|
24
|
+
`git`에서 직접 실행하려면:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
git clone https://github.com/ggujunhi247/durebak.git
|
|
28
|
+
cd durebak
|
|
29
|
+
npm ci
|
|
30
|
+
npm run build
|
|
31
|
+
node dist/cli.js --help
|
|
32
|
+
node dist/cli.js serve
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
세션 등록, MCP 연결, 요청·답변과 결과 제출은 [사용법](docs/USAGE.md)을 따릅니다. 새 설치는 사용자 홈의 `~/.durebak`에 데이터를 보관합니다. 기존 데이터 위치와 명시적인 경로 설정은 유지합니다. `register`와 `export`에서 `--out`을 생략하면 인증 파일과 기록도 같은 데이터 디렉터리에 저장됩니다. `npx --yes durebak@alpha paths`로 실제 위치를 확인할 수 있습니다.
|
|
36
|
+
|
|
37
|
+
## 검증 상태
|
|
38
|
+
|
|
39
|
+
- 실제 Codex → Codex 요청·검토·결과 제출을 검증했습니다.
|
|
40
|
+
- Claude Code·OpenCode 설정 어댑터와 6방향 시험 도구를 제공합니다. **이종 모델 간 실통신 성공은 아직 검증하지 못했습니다.**
|
|
41
|
+
- 자동 테스트와 실제 MCP 프로세스 왕복 검사를 통과했습니다. [Linux·macOS 원격 CI](https://github.com/ggujunhi247/durebak/actions/runs/36610450906)에서도 테스트와 패키지 검사를 통과했습니다.
|
|
42
|
+
- 자동 세션 깨우기·네이티브 대화 재개·무인 반복 개선은 아직 지원하지 않습니다.
|
|
43
|
+
|
|
44
|
+
자세한 버전과 제한은 [호환성](docs/COMPATIBILITY.md)을 확인하세요.
|
|
45
|
+
|
|
46
|
+
## 지금 할 수 있는 일
|
|
47
|
+
|
|
48
|
+
- 세션별 credential과 workspace 격리로 요청·답변을 교환합니다.
|
|
49
|
+
- SQLite WAL에 저장하고 동일 idempotency key의 중복 전송을 억제합니다.
|
|
50
|
+
- 우선순위·대기 시간·세션 상태에 따라 메시지를 전달하고, 수신 확인과 재시도를 관리합니다.
|
|
51
|
+
- 메시지의 읽음 확인과 작업의 수락·결과 제출을 구분합니다.
|
|
52
|
+
- 작업 version을 비교해 중복 수락이나 오래된 결과 제출을 거부합니다.
|
|
53
|
+
- 산출물을 내용 hash로 보존하고 UTF-8 원문을 최대 4 KiB씩 조회합니다.
|
|
54
|
+
- 원문 조회의 파생 캐시를 재사용하고, 모델 호출 없이 작업 기록을 Markdown으로 내보냅니다.
|
|
55
|
+
|
|
56
|
+
`completed`는 담당자가 결과를 제출했다는 뜻입니다. 독립 검토·검증에 의한 성공 판정은 아직 구현하지 않았습니다. 다른 세션의 메시지는 데이터이며 사용자의 권한을 확장하는 지시가 아닙니다.
|
|
57
|
+
|
|
58
|
+
## 검증과 개발
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npm run check
|
|
62
|
+
npm test
|
|
63
|
+
npm run package:check
|
|
64
|
+
npm run lab
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
테스트는 실제 SQLite·loopback HTTP·MCP subprocess를 사용하며 모델 API를 호출하지 않습니다. Node 24의 macOS/Linux CI를 구성했습니다. 실제 실행 환경과 검증 범위는 [구현 현황](docs/IMPLEMENTATION.md)에 기록합니다.
|
|
68
|
+
|
|
69
|
+
실제 모델을 사용하는 시험은 `npm run lab:live`로 별도 실행합니다. 계정 사용량이 발생하며 기본 대상은 Codex와 Claude입니다.
|
|
70
|
+
|
|
71
|
+
## 매뉴얼
|
|
72
|
+
|
|
73
|
+
| 목적 | 안내 |
|
|
74
|
+
|---|---|
|
|
75
|
+
| 설치·실행·메시지·기록·복구 | [사용법](docs/USAGE.md) |
|
|
76
|
+
| 호스트 연결 | [Codex](integrations/codex/README.md) · [Claude Code](integrations/claude/README.md) · [OpenCode](integrations/opencode/README.md) |
|
|
77
|
+
| 지원 환경과 한계 | [호환성](docs/COMPATIBILITY.md) |
|
|
78
|
+
| 메시지 중요도·대기·수신 확인 | [큐 정책](docs/QUEUE-POLICY.md) |
|
|
79
|
+
| credential·데이터 보호 | [보안 정책](SECURITY.md) |
|
|
80
|
+
| 개발·테스트 | [기여 안내](CONTRIBUTING.md) · [구현 현황](docs/IMPLEMENTATION.md) · [구조](docs/ARCHITECTURE.md) |
|
|
81
|
+
| 실제 호스트 시험 | [호스트 테스트](docs/HOST-TESTING.md) |
|
|
82
|
+
| 릴리스 관리 | [배포 절차](docs/RELEASING.md) · [변경점](CHANGELOG.md) |
|
|
83
|
+
|
|
84
|
+
## 배포
|
|
85
|
+
|
|
86
|
+
[Apache-2.0](LICENSE) 라이선스의 실험적 알파입니다. 소스 저장소는 [ggujunhi247/durebak](https://github.com/ggujunhi247/durebak)이며 **npm에는 아직 게시하지 않았습니다.** 현재는 위의 소스 설치 방법을 사용하세요. npm 배포 설정은 공개 `alpha` 채널용으로 준비되어 있습니다. 설정 준비와 실제 registry 게시는 별개이며, 게시 완료 전에는 위 소스 설치 방법을 사용하세요.
|
|
87
|
+
|
|
88
|
+
제품명은 **두레박**, 영문 브랜드와 CLI 식별자는 **Durebak / durebak**입니다.
|
|
89
|
+
|
|
90
|
+
메시지 전달 정책: [큐·중요도·대기·확인 규칙](docs/QUEUE-POLICY.md). 새 클라이언트는 `receive`와 `ack(id,receipt)`를 사용한다.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Security and privacy
|
|
2
|
+
|
|
3
|
+
Durebak is an early local cooperative runtime. Do not expose its HTTP port through a tunnel, reverse proxy or public interface. It binds to 127.0.0.1 and requires bearer credentials; browser Origin requests and unexpected Host headers are rejected.
|
|
4
|
+
|
|
5
|
+
The operating-system user is the trust boundary. Session credentials prevent accidental cross-workspace routing and API impersonation, but Durebak does not sandbox agents running as the same OS user. A process with filesystem access can read that user's files. All sessions registered in one workspace can discover its tasks and artifacts. Private messages can be read only by their sender and recipient; their event metadata is workspace-visible.
|
|
6
|
+
|
|
7
|
+
## Credentials and data
|
|
8
|
+
|
|
9
|
+
- Store data and session credentials outside repositories. Directories must have mode 0700; credential files must have mode 0600.
|
|
10
|
+
- `connection.json` contains the local address, not the admin credential. `admin.json` is administrative; session tokens are stored hashed in SQLite.
|
|
11
|
+
- The database contains plaintext messages, task criteria and artifact contents. Disk encryption and backups are the user's responsibility.
|
|
12
|
+
- Revocation rejects future calls; it cannot undo information already read or stop a host's model/process.
|
|
13
|
+
- Received messages, artifact text and rendered Markdown are untrusted content, not permission to execute commands, expand scope or disclose secrets.
|
|
14
|
+
- Cache clearing removes only derived local pages; it preserves original evidence. It does not delete provider-side histories or exported files.
|
|
15
|
+
- CLI/MCP do not silently retry mutating operations. Reuse an idempotency key for an identical message/task retry; inspect task revision after an uncertain completion.
|
|
16
|
+
|
|
17
|
+
## Reporting
|
|
18
|
+
|
|
19
|
+
Report vulnerabilities privately through [GitHub private vulnerability reporting](https://github.com/ggujunhi247/durebak/security/advisories/new). Do not post credentials or exploitable details in public issues. Use synthetic reproductions with tokens and private transcripts removed.
|
|
20
|
+
|
|
21
|
+
## Release gate
|
|
22
|
+
|
|
23
|
+
Before npm publication: confirm the package namespace, review the exact tarball, verify private reporting, pass the supported-platform CI matrix and complete the host integration checks required by the advertised support level. Public source availability does not imply production readiness or validated heterogeneous model communication. Public publish settings alone do not publish a package; the release still requires authenticated npm access and verification of the exact artifact.
|
|
24
|
+
|
|
25
|
+
## Publication secret checks
|
|
26
|
+
|
|
27
|
+
Install Gitleaks 8.30.1 from its official release (verify the archive checksum), then run:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm run repo:check
|
|
31
|
+
npm run secrets:selftest
|
|
32
|
+
npm run secrets:check
|
|
33
|
+
# Enable the repository-local upload guard; review any existing hook first.
|
|
34
|
+
git config --local core.hooksPath .githooks
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`GITLEAKS_BIN` can point to a verified executable. Missing scanners and scan errors fail the gate. The scanner checks all locally available Git refs, staged changes, and tracked/nonignored working files. Fetch remote refs before auditing remote history. The self-test verifies detection of uncommitted, staged-only, and deleted historical synthetic credentials, including redacted output.
|
|
38
|
+
|
|
39
|
+
The pre-push hook runs repository and secret checks before upload. Hooks are local and can be bypassed; CI repeats the checks, and the release workflow requires them before creating its artifact. CI pins the scanner version and archive SHA-256. No raw report is uploaded. These checks do not prove that every secret or personal detail has been found; review the actual diff and npm tarball too.
|
|
40
|
+
|
|
41
|
+
Ignore rules exclude host authentication/history, credentials, runtime exports, backups and raw security reports while retaining plugin manifests and synthetic fixtures. The repository check rejects force-added ignored files and personal machine paths. `.gitignore` does not remove tracked files or erase history. If a real credential was exposed, revoke/rotate it and investigate its exposure before coordinating history cleanup; deleting the file alone is insufficient.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolveHarness, legacyProvider } from './harnesses/registry.js';
|
|
3
|
+
import { version } from './version.js';
|
|
4
|
+
import { createSetup } from './setup.js';
|
|
5
|
+
import { doctor } from './doctor.js';
|
|
6
|
+
import { parseArgs } from 'node:util';
|
|
7
|
+
import { openSync, closeSync, writeFileSync, unlinkSync, realpathSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { resolve } from 'node:path';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { credential, adminCall, dataDirectory, sessionCall } from './client.js';
|
|
11
|
+
import { DomainError, fail, hash } from './domain.js';
|
|
12
|
+
import { startRuntime, operations } from './runtime.js';
|
|
13
|
+
import { serveMcp } from './mcp.js';
|
|
14
|
+
import { exportRecord } from './records.js';
|
|
15
|
+
import { storagePaths, managedCredentialPath, managedRecordPath } from './paths.js';
|
|
16
|
+
const help = `Durebak ${version} — local cooperative session bus
|
|
17
|
+
|
|
18
|
+
durebak serve [--data-dir PATH] Run loopback daemon in foreground
|
|
19
|
+
durebak register --workspace PATH --alias NAME --harness codex|claude-code|opencode|other [--out FILE] [--data-dir PATH]
|
|
20
|
+
durebak revoke SESSION_ID [--data-dir PATH] Revoke a session credential
|
|
21
|
+
durebak mcp --session FILE Start session-scoped MCP stdio bridge
|
|
22
|
+
durebak call OPERATION --session FILE [--json JSON | --input FILE]
|
|
23
|
+
durebak setup --harness codex|claude-code|opencode --session FILE --out FILE
|
|
24
|
+
durebak doctor --session FILE Check identity and runtime compatibility
|
|
25
|
+
durebak export TASK_ID --session FILE [--out FILE]
|
|
26
|
+
durebak paths [--session FILE | --data-dir PATH] Show local storage paths
|
|
27
|
+
|
|
28
|
+
Legacy --provider (register) and --host (setup) remain supported; claude aliases claude-code.
|
|
29
|
+
New installations default to ~/.durebak (explicit data-dir/environment and existing legacy data take precedence).
|
|
30
|
+
Register/export without --out use private credentials/ and records/ below the selected data directory.
|
|
31
|
+
Session credential files are private. Keep them outside your repository.
|
|
32
|
+
call operations: ${Object.keys(operations).join(', ')}
|
|
33
|
+
No provider auto-wake or managed execution in this alpha.
|
|
34
|
+
`;
|
|
35
|
+
const output = (value) => process.stdout.write(JSON.stringify(value) + '\n');
|
|
36
|
+
function required(value, name) { if (!value)
|
|
37
|
+
fail(`missing_${name}`); return value; }
|
|
38
|
+
async function main() {
|
|
39
|
+
const { values, positionals } = parseArgs({ allowPositionals: true, options: {
|
|
40
|
+
'data-dir': { type: 'string' }, workspace: { type: 'string' }, alias: { type: 'string' }, provider: { type: 'string' }, harness: { type: 'string' }, out: { type: 'string' }, session: { type: 'string' }, json: { type: 'string' }, input: { type: 'string' }, host: { type: 'string' }, help: { type: 'boolean' }, version: { type: 'boolean' },
|
|
41
|
+
} });
|
|
42
|
+
const command = positionals[0];
|
|
43
|
+
if (values.version) {
|
|
44
|
+
process.stdout.write(version + '\n');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (values.help || !command) {
|
|
48
|
+
process.stdout.write(help);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const selectedDirectory = () => dataDirectory(values['data-dir']);
|
|
52
|
+
if (command === 'paths') {
|
|
53
|
+
const session = values.session ?? process.env.DUREBAK_SESSION_FILE;
|
|
54
|
+
output(storagePaths(session ? credential(session).data_dir : selectedDirectory()));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (command === 'serve') {
|
|
58
|
+
const runtime = await startRuntime(selectedDirectory());
|
|
59
|
+
process.stderr.write(`Durebak listening at ${runtime.url}\n`);
|
|
60
|
+
let stopping = false;
|
|
61
|
+
const stop = () => { if (stopping)
|
|
62
|
+
return; stopping = true; void runtime.close().catch(() => { process.exitCode = 1; }); };
|
|
63
|
+
process.once('SIGINT', stop);
|
|
64
|
+
process.once('SIGTERM', stop);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (command === 'register') {
|
|
68
|
+
const workspace = hash(realpathSync(required(values.workspace, 'workspace')));
|
|
69
|
+
const args = { workspace, alias: required(values.alias, 'alias'), provider: legacyProvider(resolveHarness(values.harness, values.provider)) };
|
|
70
|
+
const directory = selectedDirectory();
|
|
71
|
+
const file = values.out !== undefined ? resolve(required(values.out, 'out')) : managedCredentialPath(directory);
|
|
72
|
+
const fd = openSync(file, 'wx', 0o600);
|
|
73
|
+
let registered = false;
|
|
74
|
+
try {
|
|
75
|
+
const result = z.object({ session: z.object({ id: z.string() }).passthrough(), token: z.string() }).parse(await adminCall(directory, '/v1/register', args));
|
|
76
|
+
registered = true;
|
|
77
|
+
writeFileSync(fd, JSON.stringify({ data_dir: directory, ...result }) + '\n');
|
|
78
|
+
output({ session: result.session, credential_file: file });
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
closeSync(fd);
|
|
82
|
+
if (!registered)
|
|
83
|
+
unlinkSync(file);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (command === 'revoke') {
|
|
88
|
+
output(await adminCall(selectedDirectory(), '/v1/revoke', { id: required(positionals[1], 'session_id') }));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!['setup', 'doctor', 'mcp', 'call', 'export'].includes(command))
|
|
92
|
+
fail('unknown_command');
|
|
93
|
+
const file = required(values.session ?? process.env.DUREBAK_SESSION_FILE, 'session');
|
|
94
|
+
if (command === 'setup') {
|
|
95
|
+
output(createSetup(resolveHarness(values.harness, values.host), file, required(values.out, 'out')));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (command === 'doctor') {
|
|
99
|
+
const result = await doctor(file);
|
|
100
|
+
output(result);
|
|
101
|
+
if (!result.ok)
|
|
102
|
+
process.exitCode = 1;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (command === 'mcp') {
|
|
106
|
+
await serveMcp(file);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (command === 'call') {
|
|
110
|
+
const operation = required(positionals[1], 'operation');
|
|
111
|
+
if (!Object.hasOwn(operations, operation))
|
|
112
|
+
fail('unknown_operation');
|
|
113
|
+
if (values.json && values.input)
|
|
114
|
+
fail('choose_json_or_input');
|
|
115
|
+
const text = values.input ? readFileSync(resolve(values.input), 'utf8') : values.json ?? '{}';
|
|
116
|
+
if (Buffer.byteLength(text) > 131072)
|
|
117
|
+
fail('request_too_large');
|
|
118
|
+
let input;
|
|
119
|
+
try {
|
|
120
|
+
input = JSON.parse(text);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
fail('invalid_json');
|
|
124
|
+
}
|
|
125
|
+
output(await sessionCall(file, operation, input));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (command === 'export') {
|
|
129
|
+
const result = z.object({ markdown: z.string() }).parse(await sessionCall(file, 'record', { id: required(positionals[1], 'task_id') }));
|
|
130
|
+
const config = credential(file);
|
|
131
|
+
const destination = values.out !== undefined ? resolve(required(values.out, 'out')) : managedRecordPath(config.data_dir, config.session.workspace, positionals[1], result.markdown);
|
|
132
|
+
output(exportRecord(destination, result.markdown));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
fail('unknown_command');
|
|
136
|
+
}
|
|
137
|
+
main().catch(error => {
|
|
138
|
+
const code = error instanceof DomainError ? error.code : error instanceof z.ZodError ? 'invalid_input' : error.code ?? 'operation_failed';
|
|
139
|
+
process.stderr.write(JSON.stringify({ error: code }) + '\n');
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
});
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Operation } from './runtime.js';
|
|
2
|
+
export { dataDirectory } from './paths.js';
|
|
3
|
+
export declare function privateJson(path: string): unknown;
|
|
4
|
+
export declare function credential(path: string): {
|
|
5
|
+
data_dir: string;
|
|
6
|
+
token: string;
|
|
7
|
+
session: {
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
id: string;
|
|
10
|
+
workspace: string;
|
|
11
|
+
alias: string;
|
|
12
|
+
provider: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function request(directory: string, token: string, path: string, payload: unknown): Promise<unknown>;
|
|
16
|
+
export declare function sessionCall(file: string, operation: Operation, args: unknown): Promise<unknown>;
|
|
17
|
+
export declare function adminCall(directory: string, path: '/v1/register' | '/v1/revoke', args: unknown): Promise<unknown>;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readFileSync, lstatSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { fail } from './domain.js';
|
|
5
|
+
export { dataDirectory } from './paths.js';
|
|
6
|
+
export function privateJson(path) {
|
|
7
|
+
const stat = lstatSync(path);
|
|
8
|
+
if (!stat.isFile() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0 || stat.size > 16384)
|
|
9
|
+
fail('unsafe_credential_file');
|
|
10
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
11
|
+
}
|
|
12
|
+
const credentialSchema = z.object({ data_dir: z.string(), token: z.string().regex(/^[a-f0-9]{64}$/), session: z.object({ id: z.string(), workspace: z.string(), alias: z.string(), provider: z.string() }).passthrough() }).strict();
|
|
13
|
+
export function credential(path) { return credentialSchema.parse(privateJson(path)); }
|
|
14
|
+
export async function request(directory, token, path, payload) {
|
|
15
|
+
const connection = z.object({ url: z.string(), instance: z.string() }).parse(privateJson(join(directory, 'connection.json')));
|
|
16
|
+
const url = new URL(connection.url);
|
|
17
|
+
if (url.protocol !== 'http:' || url.hostname !== '127.0.0.1' || !url.port || url.username || url.password || url.pathname !== '/' || url.search || url.hash)
|
|
18
|
+
fail('unsafe_endpoint');
|
|
19
|
+
const text = JSON.stringify(payload);
|
|
20
|
+
if (Buffer.byteLength(text) > 131072)
|
|
21
|
+
fail('request_too_large');
|
|
22
|
+
const response = await fetch(new URL(path, url), { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' }, body: text, redirect: 'error', signal: AbortSignal.timeout(15000) });
|
|
23
|
+
let resultText = '';
|
|
24
|
+
let size = 0;
|
|
25
|
+
const reader = response.body?.getReader();
|
|
26
|
+
if (!reader)
|
|
27
|
+
fail('empty_response');
|
|
28
|
+
const decoder = new TextDecoder();
|
|
29
|
+
try {
|
|
30
|
+
while (true) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done)
|
|
33
|
+
break;
|
|
34
|
+
size += value.byteLength;
|
|
35
|
+
if (size > 16384)
|
|
36
|
+
fail('response_too_large');
|
|
37
|
+
resultText += decoder.decode(value, { stream: true });
|
|
38
|
+
}
|
|
39
|
+
resultText += decoder.decode();
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await reader.cancel();
|
|
43
|
+
}
|
|
44
|
+
const result = JSON.parse(resultText);
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
const error = z.object({ error: z.string() }).parse(result);
|
|
47
|
+
fail(error.error);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
export function sessionCall(file, operation, args) {
|
|
52
|
+
const config = credential(file);
|
|
53
|
+
return request(config.data_dir, config.token, '/v1/session', { operation, args });
|
|
54
|
+
}
|
|
55
|
+
export function adminCall(directory, path, args) {
|
|
56
|
+
const admin = z.object({ token: z.string() }).parse(privateJson(join(directory, 'admin.json')));
|
|
57
|
+
return request(directory, admin.token, path, args);
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function encodedPreview(value: string, budget: number): string;
|
|
2
|
+
export declare function preview(text: string, limit: number): string;
|
|
3
|
+
export declare function range(text: string, offset: number, limit: number): {
|
|
4
|
+
content: string;
|
|
5
|
+
offset: number;
|
|
6
|
+
next: number;
|
|
7
|
+
total_bytes: number;
|
|
8
|
+
has_more: boolean;
|
|
9
|
+
};
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { fail } from './domain.js';
|
|
3
|
+
export function encodedPreview(value, budget) { let text = preview(value, 512); while (Buffer.byteLength(JSON.stringify(text)) > budget)
|
|
4
|
+
text = Array.from(text).slice(0, -1).join(''); return text; }
|
|
5
|
+
export function preview(text, limit) { return range(text, 0, limit).content; }
|
|
6
|
+
export function range(text, offset, limit) {
|
|
7
|
+
z.number().int().min(0).parse(offset);
|
|
8
|
+
z.number().int().min(4).max(4096).parse(limit);
|
|
9
|
+
const buffer = Buffer.from(text);
|
|
10
|
+
if (offset > buffer.length || (offset < buffer.length && (buffer[offset] & 0xc0) === 0x80))
|
|
11
|
+
fail('invalid_offset');
|
|
12
|
+
let end = Math.min(buffer.length, offset + limit);
|
|
13
|
+
while (end < buffer.length && (buffer[end] & 0xc0) === 0x80)
|
|
14
|
+
end--;
|
|
15
|
+
// A 4 KiB source can expand to 24 KiB in JSON. Budget the encoded
|
|
16
|
+
// content too, leaving room for metadata in the 16 KiB HTTP envelope.
|
|
17
|
+
let encodedBytes = 2;
|
|
18
|
+
let safeEnd = offset;
|
|
19
|
+
for (const character of buffer.subarray(offset, end).toString('utf8')) {
|
|
20
|
+
const size = Buffer.byteLength(JSON.stringify(character)) - 2;
|
|
21
|
+
if (encodedBytes + size > 12000)
|
|
22
|
+
break;
|
|
23
|
+
encodedBytes += size;
|
|
24
|
+
safeEnd += Buffer.byteLength(character);
|
|
25
|
+
}
|
|
26
|
+
end = safeEnd;
|
|
27
|
+
return { content: buffer.subarray(offset, end).toString('utf8'), offset, next: end, total_bytes: buffer.length, has_more: end < buffer.length };
|
|
28
|
+
}
|
package/dist/database.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { mkdirSync, lstatSync, openSync, closeSync, constants } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { fail } from './domain.js';
|
|
5
|
+
import { migrate } from './migrations.js';
|
|
6
|
+
export function privateDirectory(path) {
|
|
7
|
+
mkdirSync(path, { recursive: true, mode: 0o700 });
|
|
8
|
+
const stat = lstatSync(path);
|
|
9
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0)
|
|
10
|
+
fail('unsafe_data_directory');
|
|
11
|
+
}
|
|
12
|
+
export function openDatabase(directory) {
|
|
13
|
+
privateDirectory(directory);
|
|
14
|
+
const file = join(directory, 'runtime.sqlite');
|
|
15
|
+
try {
|
|
16
|
+
closeSync(openSync(file, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code !== 'EEXIST')
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
const stat = lstatSync(file);
|
|
23
|
+
if (!stat.isFile() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0)
|
|
24
|
+
fail('unsafe_database');
|
|
25
|
+
const db = new DatabaseSync(file);
|
|
26
|
+
try {
|
|
27
|
+
db.exec('PRAGMA busy_timeout=5000; PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON;');
|
|
28
|
+
migrate(db);
|
|
29
|
+
return db;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
db.close();
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|