larness 0.4.2 → 0.5.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/README.md +6 -5
- package/app.js +22 -105
- package/apps/server/dist/{address-BDs0FfMq.js → address-D0ZG5qR4.js} +5 -2
- package/apps/server/dist/args-CrKTPT06.js +92 -0
- package/apps/server/dist/cli.js +340 -0
- package/apps/server/dist/{client-D88ULjn9.js → client-D_Ni3Zpx.js} +21 -1
- package/apps/server/dist/code-B2JBoV4x.js +24 -0
- package/apps/server/dist/{doctor-dwTQiTef.js → doctor-CE6cONuz.js} +3 -2
- package/apps/server/dist/doctor-sPRlI92N.js +1 -0
- package/apps/server/dist/doctor.js +1 -1
- package/apps/server/dist/index.js +724 -126
- package/apps/server/dist/{paths-DUfwiH2X.js → inspect-XgAc84F9.js} +106 -87
- package/apps/server/dist/lifecycle-C3KV3-Ax.js +263 -0
- package/apps/server/dist/log-files-CFOaEy6O.js +26 -0
- package/apps/server/dist/{managed-Br7VqQiP.js → managed-Cw3MVilO.js} +221 -71
- package/apps/server/dist/paths-BhVn34MT.js +77 -0
- package/apps/server/dist/{status-D2oSIMoj.js → status-CV_zWfs6.js} +16 -3
- package/apps/server/dist/status.js +37 -9
- package/apps/server/dist/supervisor-IYDKL4iU.js +297 -0
- package/apps/server/dist/tui.js +167 -333
- package/apps/server/dist/version-ui_X8H2k.js +13 -0
- package/apps/server/drizzle/0001_auth.sql +109 -109
- package/apps/server/drizzle/0002_projects.sql +12 -12
- package/apps/server/drizzle/0003_workspace.sql +80 -80
- package/apps/server/drizzle/0004_models.sql +30 -30
- package/apps/server/drizzle/0005_resources.sql +54 -54
- package/apps/server/drizzle/0006_commands.sql +23 -23
- package/apps/server/drizzle/0007_terminals.sql +41 -41
- package/apps/server/drizzle/0008_resource_actions.sql +23 -23
- package/apps/server/drizzle/0010_services.sql +31 -31
- package/apps/web/dist/assets/{FileEditor-JaazRNUl.js → FileEditor-DnQa6Owc.js} +1 -1
- package/apps/web/dist/assets/{FileViewer-DzJpg82J.js → FileViewer-DKlF-CWF.js} +1 -1
- package/apps/web/dist/assets/{cssMode-B8mOf4OC.js → cssMode-C9KmpsHc.js} +1 -1
- package/apps/web/dist/assets/{editor.api-BQ-DCb9F.js → editor.api-BwfHyHQ6.js} +1 -1
- package/apps/web/dist/assets/{freemarker2-C1ckA1My.js → freemarker2-D41RlIQ5.js} +1 -1
- package/apps/web/dist/assets/{handlebars-suElsFdc.js → handlebars-D-7R6ic0.js} +1 -1
- package/apps/web/dist/assets/{html-CvWl95vU.js → html-CUME4rt-.js} +1 -1
- package/apps/web/dist/assets/{htmlMode-CrdRQhj8.js → htmlMode-8w7WLhnL.js} +1 -1
- package/apps/web/dist/assets/{index-C6uOTgh6.js → index-BOS3UrP1.js} +2 -2
- package/apps/web/dist/assets/{javascript-DmE3KPeg.js → javascript-_3pdDG34.js} +1 -1
- package/apps/web/dist/assets/{jsonMode-TuNjADgG.js → jsonMode-DiqocFCf.js} +1 -1
- package/apps/web/dist/assets/{liquid-C_Ceyr5s.js → liquid-j0FoiTXN.js} +1 -1
- package/apps/web/dist/assets/{lspLanguageFeatures-DZfo74cL.js → lspLanguageFeatures-Zj7K2sG4.js} +1 -1
- package/apps/web/dist/assets/main-DZIruO5x.js +157 -0
- package/apps/web/dist/assets/main-gq3n_vn8.css +1 -0
- package/apps/web/dist/assets/{mdx-D8eqTMYQ.js → mdx-CGQ8Cw6J.js} +1 -1
- package/apps/web/dist/assets/{monaco-BGhTlUO7.js → monaco-CyMA3azg.js} +3 -3
- package/apps/web/dist/assets/{python-Cx6dqJ-u.js → python-BtY34Z9A.js} +1 -1
- package/apps/web/dist/assets/{razor-u7rb64U6.js → razor-CzYHpLv5.js} +1 -1
- package/apps/web/dist/assets/{tsMode-Cu3GDz4d.js → tsMode-GZx3VEv9.js} +1 -1
- package/apps/web/dist/assets/{typescript-H0OSh9BN.js → typescript-CAfvuTDQ.js} +1 -1
- package/apps/web/dist/assets/{workers-DJ7JInlW.js → workers-C5BOxOmH.js} +1 -1
- package/apps/web/dist/assets/{xml-C_rrJhqX.js → xml-BGX4mtH7.js} +1 -1
- package/apps/web/dist/assets/{yaml-Cub5doLg.js → yaml-B2AgBtJB.js} +1 -1
- package/apps/web/dist/favicon.svg +4 -4
- package/apps/web/dist/index.html +1 -1
- package/docs/README.md +8 -1
- package/docs/guides/install.md +23 -7
- package/package.json +3 -1
- package/apps/server/dist/lock-DyEoZgG_.js +0 -101
- package/apps/web/dist/assets/main-C3xYrJa1.js +0 -157
- package/apps/web/dist/assets/main-ptChOROf.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e}from"./editor.api-
|
|
1
|
+
import{m as e}from"./editor.api-BwfHyHQ6.js";var t={comments:{blockComment:[`<!--`,`-->`]},brackets:[[`<`,`>`]],autoClosingPairs:[{open:`<`,close:`>`},{open:`'`,close:`'`},{open:`"`,close:`"`}],surroundingPairs:[{open:`<`,close:`>`},{open:`'`,close:`'`},{open:`"`,close:`"`}],onEnterRules:[{beforeText:RegExp(`<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`,`i`),afterText:/^<\/([_:\w][_:\w-.\d]*)\s*>$/i,action:{indentAction:e.IndentAction.IndentOutdent}},{beforeText:RegExp(`<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,`i`),action:{indentAction:e.IndentAction.Indent}}]},n={defaultToken:``,tokenPostfix:`.xml`,ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,``],{include:`@whitespace`},[/(<)(@qualifiedName)/,[{token:`delimiter`},{token:`tag`,next:`@tag`}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:`delimiter`},{token:`tag`},``,{token:`delimiter`}]],[/(<\?)(@qualifiedName)/,[{token:`delimiter`},{token:`metatag`,next:`@tag`}]],[/(<\!)(@qualifiedName)/,[{token:`delimiter`},{token:`metatag`,next:`@tag`}]],[/<\!\[CDATA\[/,{token:`delimiter.cdata`,next:`@cdata`}],[/&\w+;/,`string.escape`]],cdata:[[/[^\]]+/,``],[/\]\]>/,{token:`delimiter.cdata`,next:`@pop`}],[/\]/,``]],tag:[[/[ \t\r\n]+/,``],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,[`attribute.name`,``,`attribute.value`]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,[`attribute.name`,``,`attribute.value`]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,[`attribute.name`,``,`attribute.value`]],[/@qualifiedName/,`attribute.name`],[/\?>/,{token:`delimiter`,next:`@pop`}],[/(\/)(>)/,[{token:`tag`},{token:`delimiter`,next:`@pop`}]],[/>/,{token:`delimiter`,next:`@pop`}]],whitespace:[[/[ \t\r\n]+/,``],[/<!--/,{token:`comment`,next:`@comment`}]],comment:[[/[^<\-]+/,`comment.content`],[/-->/,{token:`comment`,next:`@pop`}],[/<!--/,`comment.content.invalid`],[/[<\-]/,`comment.content`]]}};export{t as conf,n as language};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e}from"./editor.api-
|
|
1
|
+
import{m as e}from"./editor.api-BwfHyHQ6.js";var t={comments:{lineComment:`#`},brackets:[[`{`,`}`],[`[`,`]`],[`(`,`)`]],autoClosingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`}],surroundingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`}],folding:{offSide:!0},onEnterRules:[{beforeText:/:\s*$/,action:{indentAction:e.IndentAction.Indent}}]},n={tokenPostfix:`.yaml`,brackets:[{token:`delimiter.bracket`,open:`{`,close:`}`},{token:`delimiter.square`,open:`[`,close:`]`}],keywords:[`true`,`True`,`TRUE`,`false`,`False`,`FALSE`,`null`,`Null`,`Null`,`~`],numberInteger:/(?:0|[+-]?[0-9]+)/,numberFloat:/(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,numberOctal:/0o[0-7]+/,numberHex:/0x[0-9a-fA-F]+/,numberInfinity:/[+-]?\.(?:inf|Inf|INF)/,numberNaN:/\.(?:nan|Nan|NAN)/,numberDate:/\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,tokenizer:{root:[{include:`@whitespace`},{include:`@comment`},[/%[^ ]+.*$/,`meta.directive`],[/---/,`operators.directivesEnd`],[/\.{3}/,`operators.documentEnd`],[/[-?:](?= )/,`operators`],{include:`@anchor`},{include:`@tagHandle`},{include:`@flowCollections`},{include:`@blockStyle`},[/@numberInteger(?![ \t]*\S+)/,`number`],[/@numberFloat(?![ \t]*\S+)/,`number.float`],[/@numberOctal(?![ \t]*\S+)/,`number.octal`],[/@numberHex(?![ \t]*\S+)/,`number.hex`],[/@numberInfinity(?![ \t]*\S+)/,`number.infinity`],[/@numberNaN(?![ \t]*\S+)/,`number.nan`],[/@numberDate(?![ \t]*\S+)/,`number.date`],[/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/,[`type`,`white`,`operators`,`white`]],{include:`@flowScalars`},[/.+?(?=(\s+#|$))/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],object:[{include:`@whitespace`},{include:`@comment`},[/\}/,`@brackets`,`@pop`],[/,/,`delimiter.comma`],[/:(?= )/,`operators`],[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/,`type`],{include:`@flowCollections`},{include:`@flowScalars`},{include:`@tagHandle`},{include:`@anchor`},{include:`@flowNumber`},[/[^\},]+/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],array:[{include:`@whitespace`},{include:`@comment`},[/\]/,`@brackets`,`@pop`],[/,/,`delimiter.comma`],{include:`@flowCollections`},{include:`@flowScalars`},{include:`@tagHandle`},{include:`@anchor`},{include:`@flowNumber`},[/[^\],]+/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],multiString:[[/^( +).+$/,`string`,`@multiStringContinued.$1`]],multiStringContinued:[[/^( *).+$/,{cases:{"$1==$S2":`string`,"@default":{token:`@rematch`,next:`@popall`}}}]],whitespace:[[/[ \t\r\n]+/,`white`]],comment:[[/#.*$/,`comment`]],flowCollections:[[/\[/,`@brackets`,`@array`],[/\{/,`@brackets`,`@object`]],flowScalars:[[/"([^"\\]|\\.)*$/,`string.invalid`],[/'([^'\\]|\\.)*$/,`string.invalid`],[/'[^']*'/,`string`],[/"/,`string`,`@doubleQuotedString`]],doubleQuotedString:[[/[^\\"]+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/"/,`string`,`@pop`]],blockStyle:[[/[>|][0-9]*[+-]?$/,`operators`,`@multiString`]],flowNumber:[[/@numberInteger(?=[ \t]*[,\]\}])/,`number`],[/@numberFloat(?=[ \t]*[,\]\}])/,`number.float`],[/@numberOctal(?=[ \t]*[,\]\}])/,`number.octal`],[/@numberHex(?=[ \t]*[,\]\}])/,`number.hex`],[/@numberInfinity(?=[ \t]*[,\]\}])/,`number.infinity`],[/@numberNaN(?=[ \t]*[,\]\}])/,`number.nan`],[/@numberDate(?=[ \t]*[,\]\}])/,`number.date`]],tagHandle:[[/\![^ ]*/,`tag`]],anchor:[[/[&*][^ ]+/,`namespace`]]}};export{t as conf,n as language};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
2
|
-
<rect width="64" height="64" rx="16" fill="#0A84FF"/>
|
|
3
|
-
<path d="M22 17h7v24h15v6H22z" fill="#fff"/>
|
|
4
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
2
|
+
<rect width="64" height="64" rx="16" fill="#0A84FF"/>
|
|
3
|
+
<path d="M22 17h7v24h15v6H22z" fill="#fff"/>
|
|
4
|
+
</svg>
|
package/apps/web/dist/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
8
8
|
<title>Larness</title>
|
|
9
9
|
<style>.startup{text-align:center;background:var(--canvas,#f4f4f6);color:var(--ink,#1d1d1f);--startup-muted:var(--ink-3,#8a8a91);--startup-fill:var(--accent,#0a84ff);place-content:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:none;position:fixed;inset:0}[data-theme=dark] .startup{background:var(--canvas,#161618);color:var(--ink,#f2f2f5);--startup-muted:var(--ink-3,#7e7e87);--startup-fill:var(--accent,#3d9bff)}#root:empty+.startup{display:grid}.startup-wordmark{letter-spacing:.06em;color:#0000;background:radial-gradient(ellipse 25% 100% at center bottom, var(--startup-fill) 97%, transparent) 0 calc(50% - .12em) / 1.5em .24em repeat-x, radial-gradient(ellipse 25% 100% at center top, var(--startup-muted) 97%, transparent) -.75em calc(50% + .12em) / 1.5em .24em repeat-x, linear-gradient(var(--startup-muted) 50%, var(--startup-fill) 50%);-webkit-background-clip:text;background-clip:text;font-size:clamp(2rem,9vw,3.5rem);font-weight:800;line-height:1;animation:1.6s linear infinite startup-wave}.startup a{color:var(--startup-fill)}@keyframes startup-wave{to{background-position-x:-1.5em,-2.25em,0}}@media (prefers-reduced-motion:reduce),(forced-colors:active){.startup-wordmark{animation:none}}@media (forced-colors:active){.startup-wordmark{color:canvastext}}</style>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-BOS3UrP1.js"></script>
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div id="root"></div>
|
package/docs/README.md
CHANGED
|
@@ -8,10 +8,17 @@
|
|
|
8
8
|
| [architecture/stack.md](architecture/stack.md) | 冻结技术栈、workspace 结构、依赖升级规则 | 选型、加依赖、搭脚手架 |
|
|
9
9
|
| [architecture/security.md](architecture/security.md) | 信任模型、审批分级、认证、秘密、预览隔离、失败关闭矩阵 | 涉及认证 / 工具 / 代理 / 审批 |
|
|
10
10
|
| [architecture/ui-feedback.md](architecture/ui-feedback.md) | 统一消息反馈:Toast 的用法、位置、例外与检查清单 | 新增任何成功 / 失败 / 状态提示 |
|
|
11
|
-
| [contracts/rest-api.md](contracts/rest-api.md) | REST 约定、错误码、M0–M5
|
|
11
|
+
| [contracts/rest-api.md](contracts/rest-api.md) | REST 约定、错误码、M0–M5 与发布后切片接口契约 | 写 API 或前端请求 |
|
|
12
12
|
| [contracts/ws-events.md](contracts/ws-events.md) | 事件包络、序号、重放、主题与事件类型 | 写实时链路 |
|
|
13
13
|
| [contracts/ipc.md](contracts/ipc.md) | 本机 TUI ↔ Server 的 NDJSON 协议、方法与事件 | 写 TUI / IPC |
|
|
14
|
+
| [contracts/tui.md](contracts/tui.md) | TUI 页面、按键与受管入口行为 | 改 TUI 界面或交互 |
|
|
15
|
+
| [contracts/runtime-entry.md](contracts/runtime-entry.md) | 开发 / 打包统一入口、canonical origin 与端口 | 改启动方式或来源校验 |
|
|
14
16
|
| [contracts/services-preview.md](contracts/services-preview.md) | 临时服务、Terminal 绑定、隔离预览与结果卡片 | 写服务 / 预览 / AI 结果入口 |
|
|
17
|
+
| [contracts/m3-preview.md](contracts/m3-preview.md) | M3 服务登记与预览技术契约(历史条款,顶部有 083 修订) | 追溯预览票据 / 执行身份细节 |
|
|
18
|
+
| [contracts/m2-resources.md](contracts/m2-resources.md) | M2 文件、终端、命令与 Git 资源契约 | 写资源 Manager 或迁移其规则 |
|
|
19
|
+
| [contracts/deployment.md](contracts/deployment.md) | 正式 PM2 服务的部署、版本、健康与对账 | 改部署或服务运维 |
|
|
20
|
+
| [contracts/agent-command-context.md](contracts/agent-command-context.md) | 命令工具、项目锁与 PM2 系统上下文、工具结果口径 | 改命令 / 文件工具或系统提示 |
|
|
21
|
+
| [contracts/model-connections-draft.md](contracts/model-connections-draft.md) | 模型连接、能力目录与预设草案 | 改模型连接或能力来源 |
|
|
15
22
|
| [contracts/resource-views.md](contracts/resource-views.md) | 全局资源、窗口、Tab 归属、项目筛选与去重 | 写窗口 / Tab / 终端 / 服务 |
|
|
16
23
|
| [contracts/data-model.md](contracts/data-model.md) | SQLite 表、索引、迁移、保留与备份 | 写 migration / repository |
|
|
17
24
|
| [adr/DECISIONS.md](adr/DECISIONS.md) | 已冻结 ADR 与新增 ADR 流程 | 需要偏离现有决策 |
|
package/docs/guides/install.md
CHANGED
|
@@ -15,16 +15,30 @@
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install -g larness
|
|
18
|
-
larness
|
|
18
|
+
larness start
|
|
19
|
+
larness tui
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
`larness`
|
|
22
|
+
`larness start` 在后台启动管理面(Server;打包模式由 Server 提供已构建 Web),就绪后返回,关闭终端不会停止服务。首次运行初始化仍在 TUI 完成:执行 `larness tui` 按向导配置,然后在面板配对浏览器。
|
|
23
|
+
|
|
24
|
+
常用命令:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
larness status # 是否在运行、PID、地址、日志与数据目录
|
|
28
|
+
larness logs --lines 50 # 最近日志;--daemon 看后台输出;-f 跟随
|
|
29
|
+
larness tui # 打开控制面板;退出面板不会停止服务
|
|
30
|
+
larness stop # 停止管理面;PM2 正式服务继续运行
|
|
31
|
+
larness restart # 配置修改需要重启时使用
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`larness` / `node app.js` 不带参数时只打印帮助,不再直接启动服务。`pnpm dev` 仍是前台开发入口:Vite + 源码 Server + TUI 绑定在同一终端,退出即停止;`larness start` 只运行构建产物。
|
|
22
35
|
|
|
23
36
|
Windows 原生(PowerShell / cmd)直接运行同一命令。不要用 WSL 结果替代 Windows 原生验证:
|
|
24
37
|
|
|
25
38
|
```powershell
|
|
26
39
|
npm install -g larness
|
|
27
|
-
larness
|
|
40
|
+
larness start
|
|
41
|
+
larness tui
|
|
28
42
|
```
|
|
29
43
|
|
|
30
44
|
Windows Terminal 或系统自带的 conhost 均可;建议使用 Windows Terminal 获得更好的 Unicode 与缩放体验。
|
|
@@ -33,23 +47,25 @@ Larness 内新开的 Windows 交互终端依次尝试 PowerShell 7、Windows Pow
|
|
|
33
47
|
|
|
34
48
|
```bash
|
|
35
49
|
larness --version # 当前版本
|
|
36
|
-
larness status #
|
|
50
|
+
larness status # 状态摘要;--json 供脚本
|
|
37
51
|
larness doctor # 本机诊断
|
|
38
52
|
```
|
|
39
53
|
|
|
40
54
|
## 升级
|
|
41
55
|
|
|
42
|
-
Larness **不会自动更新**。TUI 启动时和每日检查公共 npm 并提示新版本。等待 Agent Turn
|
|
56
|
+
Larness **不会自动更新**。TUI 启动时和每日检查公共 npm 并提示新版本。等待 Agent Turn、部署和数据库写入完成后,先停止管理面,再安装新版本;后台运行不会因为关终端而结束。
|
|
43
57
|
|
|
44
58
|
```bash
|
|
59
|
+
larness stop
|
|
45
60
|
npm install -g larness@latest
|
|
61
|
+
larness start
|
|
46
62
|
```
|
|
47
63
|
|
|
48
|
-
|
|
64
|
+
升级后无需重新打开 TUI;`larness tui` 可随时附加。新版本首次启动会在数据库迁移前自动备份到数据目录的 `backups/`;备份失败会拒绝迁移并退出。
|
|
49
65
|
|
|
50
66
|
## 降级
|
|
51
67
|
|
|
52
|
-
|
|
68
|
+
先执行 `larness stop` 等待在途作业结束,再安装旧版本。
|
|
53
69
|
|
|
54
70
|
```bash
|
|
55
71
|
npm install -g larness@<version>
|
package/package.json
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
"test:poc:m4": "LARNESS_POC_PM2=1 pnpm --filter @larness/server exec vitest run test/resources/m4-poc.test.ts",
|
|
32
32
|
"test:poc:m5-1b": "pnpm --filter @larness/server exec tsx scripts/poc-m5-1b.ts",
|
|
33
33
|
"test:pm2:m4": "LARNESS_POC_PM2=1 pnpm --filter @larness/server exec vitest run test/resources/service-ops-pm2.test.ts test/resources/m4-4-integration.test.ts",
|
|
34
|
+
"bench:agent": "pnpm --filter @larness/server exec tsx scripts/agent-benchmark/agent-benchmark.ts",
|
|
35
|
+
"bench:rounds": "pnpm --filter @larness/server exec tsx scripts/agent-benchmark/rounds.ts",
|
|
34
36
|
"verify:pack": "node scripts/verify-npm-pack.mjs",
|
|
35
37
|
"test:platform": "node scripts/platform-smoke.mjs"
|
|
36
38
|
},
|
|
@@ -75,7 +77,7 @@
|
|
|
75
77
|
"bin": {
|
|
76
78
|
"larness": "app.js"
|
|
77
79
|
},
|
|
78
|
-
"version": "0.
|
|
80
|
+
"version": "0.5.1",
|
|
79
81
|
"description": "Larness — local-first agent workspace for projects, terminals, services and deployments",
|
|
80
82
|
"license": "MIT",
|
|
81
83
|
"keywords": [
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
3
|
-
// src/bootstrap/lock.ts
|
|
4
|
-
var InstanceLockedError = class extends Error {
|
|
5
|
-
pid;
|
|
6
|
-
constructor(pid, message) {
|
|
7
|
-
super(message ?? `another Larness instance is already running (pid ${pid ?? "unknown"})`);
|
|
8
|
-
this.name = "InstanceLockedError";
|
|
9
|
-
this.pid = pid;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function lockFilePath(dataDir) {
|
|
13
|
-
return path.join(dataDir, "larness.lock");
|
|
14
|
-
}
|
|
15
|
-
function isProcessAlive(pid) {
|
|
16
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
17
|
-
try {
|
|
18
|
-
process.kill(pid, 0);
|
|
19
|
-
return true;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
return error.code === "EPERM";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function parseRecord(text) {
|
|
25
|
-
try {
|
|
26
|
-
const value = JSON.parse(text);
|
|
27
|
-
if (typeof value !== "object" || value === null || !("pid" in value) || !("startedAt" in value) || !("version" in value)) return null;
|
|
28
|
-
const { pid, startedAt, version } = value;
|
|
29
|
-
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || typeof startedAt !== "number" || typeof version !== "string") return null;
|
|
30
|
-
return {
|
|
31
|
-
pid,
|
|
32
|
-
startedAt,
|
|
33
|
-
version
|
|
34
|
-
};
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function readRecord(lockPath) {
|
|
40
|
-
try {
|
|
41
|
-
return parseRecord(await readFile(lockPath, "utf8"));
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async function inspectInstanceLock(dataDir) {
|
|
47
|
-
const lockPath = lockFilePath(dataDir);
|
|
48
|
-
try {
|
|
49
|
-
await readFile(lockPath);
|
|
50
|
-
} catch {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const record = await readRecord(lockPath);
|
|
54
|
-
return {
|
|
55
|
-
path: lockPath,
|
|
56
|
-
record,
|
|
57
|
-
alive: record !== null && isProcessAlive(record.pid)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
async function removeIfUnchanged(lockPath, expected) {
|
|
61
|
-
try {
|
|
62
|
-
const current = parseRecord(await readFile(lockPath, "utf8"));
|
|
63
|
-
if (current === null || current.pid !== expected.pid || current.startedAt !== expected.startedAt) return;
|
|
64
|
-
await unlink(lockPath);
|
|
65
|
-
} catch {}
|
|
66
|
-
}
|
|
67
|
-
async function acquireInstanceLock(dataDir, options) {
|
|
68
|
-
const lockPath = lockFilePath(dataDir);
|
|
69
|
-
const record = {
|
|
70
|
-
pid: options.pid ?? process.pid,
|
|
71
|
-
startedAt: (options.now ?? Date.now)(),
|
|
72
|
-
version: options.version
|
|
73
|
-
};
|
|
74
|
-
for (let attempt = 0; attempt < 2; attempt += 1) try {
|
|
75
|
-
await writeFile(lockPath, `${JSON.stringify(record)}\n`, {
|
|
76
|
-
flag: "wx",
|
|
77
|
-
mode: 384
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
...record,
|
|
81
|
-
path: lockPath
|
|
82
|
-
};
|
|
83
|
-
} catch (error) {
|
|
84
|
-
if (error.code !== "EEXIST") throw error;
|
|
85
|
-
const existing = await readRecord(lockPath);
|
|
86
|
-
if (existing === null) throw new InstanceLockedError(null, `lock file is unreadable: ${lockPath}; verify no server is running before removing it`);
|
|
87
|
-
if (isProcessAlive(existing.pid)) throw new InstanceLockedError(existing.pid);
|
|
88
|
-
await removeIfUnchanged(lockPath, existing);
|
|
89
|
-
}
|
|
90
|
-
throw new InstanceLockedError(null, "failed to acquire the instance lock after a stale-lock retry");
|
|
91
|
-
}
|
|
92
|
-
async function releaseInstanceLock(lock) {
|
|
93
|
-
const current = await readRecord(lock.path);
|
|
94
|
-
if (current === null || current.pid !== lock.pid) return;
|
|
95
|
-
try {
|
|
96
|
-
await unlink(lock.path);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (error.code !== "ENOENT") throw error;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export { inspectInstanceLock as n, releaseInstanceLock as r, acquireInstanceLock as t };
|