@agfpd/iapeer 0.2.77 → 0.2.79

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.
Files changed (113) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +2 -2
  3. package/package.json +21 -2
  4. package/src/cli/index.ts +95 -78
  5. package/src/connect/index.ts +4 -4
  6. package/src/core/constants.ts +3 -3
  7. package/src/core/normalize.ts +2 -2
  8. package/src/create/index.ts +1 -1
  9. package/src/daemon/index.ts +5 -5
  10. package/src/daemon/main.ts +9 -9
  11. package/src/enable/index.ts +19 -18
  12. package/src/enable/provisionCommand.ts +10 -10
  13. package/src/identity/index.ts +2 -2
  14. package/src/identity/profileStandard.ts +8 -8
  15. package/src/init/index.ts +10 -10
  16. package/src/install/index.ts +2 -2
  17. package/src/install/signing.ts +3 -4
  18. package/src/launch/adapters/claude.ts +7 -7
  19. package/src/launch/adapters/codex.ts +5 -6
  20. package/src/launch/canary.ts +8 -8
  21. package/src/launch/cmdlog.ts +3 -3
  22. package/src/launch/composeSystemPrompt.ts +2 -1
  23. package/src/launch/index.ts +5 -6
  24. package/src/launch/invocation.ts +1 -1
  25. package/src/launch/launchd.ts +14 -15
  26. package/src/launch/launchdRun.ts +6 -6
  27. package/src/launch/nativeMemory.ts +9 -9
  28. package/src/launch/ptyHost.ts +1 -1
  29. package/src/launch/readyGateModel.ts +3 -3
  30. package/src/launch/types.ts +7 -7
  31. package/src/lifecycle/eventlog.ts +2 -2
  32. package/src/lifecycle/index.ts +21 -21
  33. package/src/lifecycle/queue.ts +1 -1
  34. package/src/onboard/index.ts +19 -13
  35. package/src/onboard/memory.ts +5 -5
  36. package/src/onboard/steps.ts +8 -9
  37. package/src/provision/index.ts +2 -3
  38. package/src/runtime/deploy.ts +2 -2
  39. package/src/runtime/index.ts +4 -4
  40. package/src/shadow/gate.ts +6 -6
  41. package/src/shadow/index.ts +2 -2
  42. package/src/status/index.ts +11 -11
  43. package/src/storage/index.ts +1 -1
  44. package/src/supervisor/daemon.ts +20 -13
  45. package/src/transport/index.ts +11 -11
  46. package/src/update/index.ts +4 -4
  47. package/src/cli/cli.test.ts +0 -603
  48. package/src/cli/listTui.test.ts +0 -71
  49. package/src/codec/codec.test.ts +0 -271
  50. package/src/connect/connect.test.ts +0 -163
  51. package/src/core/constants.test.ts +0 -32
  52. package/src/core/normalize.test.ts +0 -98
  53. package/src/create/create.test.ts +0 -143
  54. package/src/daemon/daemon-http.test.ts +0 -114
  55. package/src/daemon/daemon.test.ts +0 -267
  56. package/src/daemon/main.test.ts +0 -413
  57. package/src/enable/enable.test.ts +0 -95
  58. package/src/enable/provisionCommand.test.ts +0 -107
  59. package/src/identity/identity.test.ts +0 -279
  60. package/src/identity/profileStandard.test.ts +0 -204
  61. package/src/init/init.test.ts +0 -215
  62. package/src/init/runtime-resolve.test.ts +0 -49
  63. package/src/install/install.test.ts +0 -66
  64. package/src/install/signing.test.ts +0 -84
  65. package/src/launch/bootdeliver.test.ts +0 -108
  66. package/src/launch/bootstrap.test.ts +0 -56
  67. package/src/launch/canary.test.ts +0 -346
  68. package/src/launch/cmdlog.test.ts +0 -94
  69. package/src/launch/codexHooksTrust.test.ts +0 -248
  70. package/src/launch/composeSystemPrompt.layers.test.ts +0 -445
  71. package/src/launch/composeSystemPrompt.test.ts +0 -145
  72. package/src/launch/hostComposerOccupied.test.ts +0 -63
  73. package/src/launch/invocation.test.ts +0 -174
  74. package/src/launch/launch.test.ts +0 -359
  75. package/src/launch/launchd.test.ts +0 -499
  76. package/src/launch/nativeMemory.test.ts +0 -193
  77. package/src/launch/ptyHost.test.ts +0 -38
  78. package/src/launch/readyGateModel.test.ts +0 -72
  79. package/src/launch/sockdir.test.ts +0 -74
  80. package/src/lifecycle/eventlog.test.ts +0 -114
  81. package/src/lifecycle/lifecycle.test.ts +0 -1056
  82. package/src/lifecycle/queue.test.ts +0 -185
  83. package/src/onboard/memory.test.ts +0 -157
  84. package/src/onboard/onboard.test.ts +0 -39
  85. package/src/onboard/steps.test.ts +0 -201
  86. package/src/provision/provision.test.ts +0 -288
  87. package/src/registry/registry.test.ts +0 -432
  88. package/src/runtime/runtime.test.ts +0 -226
  89. package/src/runtime/update.test.ts +0 -192
  90. package/src/shadow/enumerate-skip.test.ts +0 -67
  91. package/src/shadow/gate.test.ts +0 -286
  92. package/src/shadow/install.test.ts +0 -153
  93. package/src/shadow/shadow.test.ts +0 -42
  94. package/src/status/status.test.ts +0 -208
  95. package/src/storage/peers-home.test.ts +0 -34
  96. package/src/storage/rotatelog.test.ts +0 -44
  97. package/src/storage/storage.test.ts +0 -65
  98. package/src/supervisor/attached-marker.test.ts +0 -84
  99. package/src/supervisor/boot.test.ts +0 -66
  100. package/src/supervisor/client.attach.test.ts +0 -107
  101. package/src/supervisor/daemon.test.ts +0 -213
  102. package/src/supervisor/deliver.test.ts +0 -58
  103. package/src/supervisor/panelog.test.ts +0 -95
  104. package/src/supervisor/protocol.test.ts +0 -222
  105. package/src/supervisor/selfargv.test.ts +0 -22
  106. package/src/supervisor/spinner-strip.test.ts +0 -52
  107. package/src/transport/compactDone.test.ts +0 -144
  108. package/src/transport/composerQueue.test.ts +0 -204
  109. package/src/transport/hostControl.test.ts +0 -87
  110. package/src/transport/hostDeliver.test.ts +0 -137
  111. package/src/transport/hostLive.test.ts +0 -50
  112. package/src/transport/routesend-wake.test.ts +0 -357
  113. package/src/update/update.test.ts +0 -208
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 2026 Artur Agafapudov
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
@@ -22,8 +22,8 @@ iapeer держит AI-агентов как **живые интерактивн
22
22
 
23
23
  ## Документация
24
24
 
25
- Документация проекта — в [`docs/`](docs/README.md): продуктовая часть (что это и как пользоваться) и механика изнутри ([`docs/internals/`](docs/internals/README.md)). Этот репозиторий — кодовая реализация.
25
+ Документация проекта — в [`docs/`](https://github.com/agfpd/iapeer/tree/main/docs): продуктовая часть (что это и как пользоваться) и механика изнутри ([`docs/internals/`](https://github.com/agfpd/iapeer/tree/main/docs/internals)). Этот репозиторий — кодовая реализация.
26
26
 
27
27
  ## Статус
28
28
 
29
- Версия — **0.2.73**. Платформа — macOS/launchd.
29
+ Платформа — macOS/launchd. Актуальная версия — в `package.json` / `iapeer version`.
package/package.json CHANGED
@@ -1,7 +1,25 @@
1
1
  {
2
2
  "name": "@agfpd/iapeer",
3
- "version": "0.2.77",
3
+ "version": "0.2.79",
4
4
  "description": "Foundation core for the iapeer multi-agent ecosystem: identity, registry, storage, codec.",
5
+ "license": "Apache-2.0",
6
+ "author": "agfpd",
7
+ "homepage": "https://github.com/agfpd/iapeer#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/agfpd/iapeer.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/agfpd/iapeer/issues"
14
+ },
15
+ "keywords": [
16
+ "multi-agent",
17
+ "agents",
18
+ "mcp",
19
+ "ipc",
20
+ "launchd",
21
+ "bun"
22
+ ],
5
23
  "type": "module",
6
24
  "bin": {
7
25
  "iapeer": "bin/iapeer"
@@ -9,7 +27,8 @@
9
27
  "files": [
10
28
  "src",
11
29
  "bin",
12
- "tsconfig.json"
30
+ "tsconfig.json",
31
+ "!src/**/*.test.ts"
13
32
  ],
14
33
  "exports": {
15
34
  ".": "./src/index.ts",
package/src/cli/index.ts CHANGED
@@ -102,7 +102,7 @@ export interface PeerListing {
102
102
  /** The peer's working directory (registry fact). Machine-readable so host-local
103
103
  * tooling (e.g. the memory provider's init/verify rendering doctrine into
104
104
  * <cwd>/.iapeer/) keys on the REGISTRY instead of copying the layout default —
105
- * a layout change must not silently strand consumers (iapeer-memory ask, 10.06). */
105
+ * a layout change must not silently strand consumers. */
106
106
  cwd: string
107
107
  runtimes: RuntimeStatus[]
108
108
  }
@@ -235,8 +235,8 @@ export function stopPeer(personality: string, runtime: string | undefined, opts:
235
235
  killSession(sock, identity)
236
236
  out.push({ personality, runtime: rt, action: 'bootout', reason: r.status === 0 ? undefined : `launchctl bootout exited ${r.status}${(r.stderr ?? '').trim() ? `: ${(r.stderr ?? '').trim()}` : ''}` })
237
237
  } else {
238
- // A deliberate stop is a CLEAN PARK, not a death (boris 10.06 — stop→start
239
- // must survive ≥ idle-reap): park-mark BEFORE the kill so the post-`start`
238
+ // A deliberate stop is a CLEAN PARK, not a death (stop→start must survive ≥
239
+ // idle-reap): park-mark BEFORE the kill so the post-`start`
240
240
  // wake RESUMES, and drop the supervise session-state with the session so
241
241
  // the tick never tags this kill as a death (crash-loop ring stays clean,
242
242
  // no reaped-gone death class for a state the daemon knows 100%).
@@ -268,8 +268,8 @@ export function startPeer(personality: string, runtime: string | undefined, opts
268
268
  const identity = buildProcessAddress(rt, personality)
269
269
  if (isInfraRuntime(rt)) {
270
270
  const plist = launchdPlistPath(personality, env)
271
- // UNDEAD-JOB-SAFE start (boris's connect-acceptance find 10.06): a bootstrap
272
- // right after a bootout used to hit the still-dismantling job (exit 5 I/O
271
+ // UNDEAD-JOB-SAFE start: a bootstrap right after a bootout used to hit the
272
+ // still-dismantling job (exit 5 I/O
273
273
  // error) and leave the router DOWN. launchctlBootstrap now waits for the
274
274
  // job to vanish and retries with backoff (~22 s budget); a failure after
275
275
  // every attempt is LOUD with the manual rescue recipe. (Also gains the
@@ -300,8 +300,8 @@ export interface AddRuntimeOutcome {
300
300
 
301
301
  /**
302
302
  * add-runtime <runtime> (--peer <p> | --all) — give EXISTING peers an additional
303
- * AGENTIC runtime in one command (codex-parity audit, директива Артура 12.06: the
304
- * fleet-switch enabler — 14/23 peers were claude-only with nothing to switch to).
303
+ * AGENTIC runtime in one command (the fleet-switch enabler — a claude-only peer
304
+ * has nothing to switch to).
305
305
  * Per target: initPeer({cwd, runtime}) — ensurePeerProfile MERGES runtimes (the
306
306
  * default_runtime lever is deliberately untouched — capability ≠ routing flip; see
307
307
  * `default-runtime`), scaffolds the runtime scope, and the codex side runs its
@@ -325,8 +325,8 @@ export async function addRuntime(
325
325
  if (targets.length === 0) throw new Error(opts.peer ? `peer "${opts.peer}" is not registered` : 'no targets — pass --peer <p> or --all')
326
326
  // CROSS-PEER operation: strip the CALLER's identity env (PEER_*) — an operator
327
327
  // (or an agent peer) running this from inside their own session would otherwise
328
- // poison the TARGET's ensurePeerProfile identity check (live-caught on the very
329
- // first 0.2.45 probe: PEER_PERSONALITY="iapeer" vs target "twpar" → failed).
328
+ // poison the TARGET's ensurePeerProfile identity check (the caller's
329
+ // PEER_PERSONALITY would mismatch the target personality → failed).
330
330
  const cleanEnv: NodeJS.ProcessEnv = { ...env }
331
331
  delete cleanEnv.PEER_PERSONALITY
332
332
  delete cleanEnv.PEER_RUNTIME
@@ -353,8 +353,8 @@ export async function addRuntime(
353
353
  // Self-heal the registry from the locals: provisionPeer's upsert sets the record's
354
354
  // default to the PROVISIONED runtime («args.runtime wins» — right for births, wrong
355
355
  // here: add-runtime is capability-only and must NOT flip routing). The reindex
356
- // REPLACE projection restores the local profile's untouched default (live-caught
357
- // on the 0.2.45 probe: registry default flipped to codex while the local kept claude).
356
+ // REPLACE projection restores the local profile's untouched default (otherwise
357
+ // the registry default flips to the added runtime while the local keeps its own).
358
358
  if (out.some(o => o.action === 'added')) await reindexFromLocals({ env })
359
359
  return out
360
360
  }
@@ -367,8 +367,8 @@ export interface DefaultRuntimeOutcome {
367
367
 
368
368
  /**
369
369
  * default-runtime <runtime> (--peer <p> | --all) — flip the PRIMARY lever
370
- * (contract Идентичность: primary держит default_runtime, НЕ порядок runtimes[];
371
- * linus precedent 11.06). This is the routing/wake/first-launch default — the
370
+ * (contract Идентичность: primary держит default_runtime, НЕ порядок runtimes[]).
371
+ * This is the routing/wake/first-launch default — the
372
372
  * actual fleet-switch moment is a mass flip of exactly this field. The local
373
373
  * profile is rewritten through the H1 merge-writer (default_runtime + the legacy
374
374
  * in-sync mirror; normalizeRuntimes re-prepends the new default), then the
@@ -432,7 +432,7 @@ export interface NewPeerOutcome {
432
432
 
433
433
  /**
434
434
  * new <peer> [runtime] — the UNCONDITIONAL fresh-restart control command
435
- * (docs/Control-команды §new; постановка boris 01:32 12.06, санкция Артура).
435
+ * (docs/Control-команды §new).
436
436
  *
437
437
  * The emergency lever for a HUNG or dead agent session: /alias-new covers only
438
438
  * the COOPERATIVE path (a live peer reads the expanded prompt and runs
@@ -444,7 +444,7 @@ export interface NewPeerOutcome {
444
444
  * wakeOrSpawn(resume:false, task:'') — fresh BY CONSTRUCTION, the same recipe
445
445
  * as the eager relaunch (the C2 initial_prompt seeds the first turn).
446
446
  *
447
- * exit-0 contract (сверка telegram-runtime): success ⟺ the fresh session is UP
447
+ * exit-0 contract: success ⟺ the fresh session is UP
448
448
  * and READY (verified by the wake's ready gate, not merely scheduled) — for a
449
449
  * sleeping, dead AND hung target alike. Duration is a real TUI boot: typically
450
450
  * 5–30 s, bounded by cfg.bootDeadlineSecs. Idempotent in effect: each repeat
@@ -645,7 +645,7 @@ export interface RemoveOutcome {
645
645
  reason?: string
646
646
  /** The removed peer's cwd (registry fact, captured BEFORE the removal). remove
647
647
  * deliberately keeps the folder — user data is never deleted by a registry reap
648
- * (boris's finding 10.06: say so in the output instead of leaving silent orphans). */
648
+ * (say so in the output instead of leaving silent orphans). */
649
649
  cwd?: string
650
650
  /** v1.2: per-runtime unprovision outcomes (`<rt>:<state>`), present when the
651
651
  * slot declares an unprovision command (occasion=remove ran before the purge). */
@@ -660,8 +660,8 @@ export interface RemoveOutcome {
660
660
  codexHooksTrust?: string
661
661
  /** Identity-keyed lifecycle artifacts purged with the record (state/lifecycle/
662
662
  * `<identity>.*` per runtime). Without this purge a NEWBORN peer reusing the
663
- * personality inherits the dead namesake's parking (live defect, boris 10.06:
664
- * stale .stopped → `mode=refused cause=stopped` on a freshly-created peer). */
663
+ * personality inherits the dead namesake's parking (defect: stale .stopped →
664
+ * `mode=refused cause=stopped` on a freshly-created peer). */
665
665
  purgedState?: string[]
666
666
  }
667
667
 
@@ -734,7 +734,7 @@ export async function removePeerCli(
734
734
  unprovisionOutcomes.push(`failed: ${e instanceof Error ? e.message : String(e)}`)
735
735
  }
736
736
  // Codex pre-trust cleanup (reap-side counterpart of the birth-time
737
- // preTrustCodexCwd; backlog made live by D4 11.06): a removed codex peer must
737
+ // preTrustCodexCwd): a removed codex peer must
738
738
  // not leave its cwd trusted in the host ~/.codex/config.toml forever. After
739
739
  // unprovision (the provider sees the peer's last consistent state first),
740
740
  // best-effort like everything else on this path.
@@ -800,7 +800,7 @@ export async function sendMessage(
800
800
  ): Promise<{ ok: true; delivered_to: { personality: string; runtime: string }; queued?: boolean; queueDepth?: number }> {
801
801
  const env = opts.env ?? process.env
802
802
  const caller = resolveCallerIdentity(parseIdentity(opts.from), readPeersIndex({ env }))
803
- // wake_policy:ephemeral M3 parity (iapeer-memory ask, 10.06): the CLI path used
803
+ // wake_policy:ephemeral M3 parity: the CLI path used
804
804
  // to route an ephemeral target through the normal live/miss path — a notifier
805
805
  // burst landed as TURNS in one live worker session instead of serializing
806
806
  // through the disk FIFO the daemon path uses. Same seam, ONE difference: the
@@ -822,12 +822,12 @@ export async function sendMessage(
822
822
  },
823
823
  // noteLiveTopic — CLI-path parity (same seam the daemon wires): a live delivery
824
824
  // through the CLI fallback must update the target's .topic marker too, or a
825
- // daemon-restart-window send re-opens the stale-marker false-fresh (defect 11.06).
825
+ // daemon-restart-window send re-opens the stale-marker false-fresh.
826
826
  { wake: cliWake, ephemeral: makeEphemeralRouteDeps(cfg, env, () => {}), noteLiveTopic: makeNoteLiveTopic(cfg, env) },
827
827
  )
828
- // delivery.log sink — CLI-path parity (boris's observability gap 10.06: enqueues
829
- // routed through the CLI left to=<peer> at ZERO for the day while real wakes
830
- // happened; the daemon tool-path logs, this path was blind). Same fields, plus
828
+ // delivery.log sink — CLI-path parity (observability gap: enqueues routed
829
+ // through the CLI left to=<peer> at ZERO while real wakes happened; the daemon
830
+ // tool-path logs, this path was blind). Same fields, plus
831
831
  // path=cli so the two entry points are distinguishable. Both branches logged.
832
832
  const { appendDeliveryEvent } = await import('../daemon/deliverylog.ts')
833
833
  appendDeliveryEvent(cfg.eventLogDir, {
@@ -849,10 +849,10 @@ export async function sendMessage(
849
849
  err: result.ok ? undefined : result.error.message,
850
850
  })
851
851
  if (!result.ok) throw new Error(result.error.message)
852
- // M2 arm-on-outbound — CLI-path parity (live gap 10.06: an ephemeral worker's
853
- // final reply sent through the CLI fallback — e.g. inside a daemon-restart
854
- // window, four deploys that day — never armed, so the worker idled to the
855
- // unarmed bound and stalled its FIFO). Same hook the daemon path uses; ONLY on
852
+ // M2 arm-on-outbound — CLI-path parity (gap: an ephemeral worker's final reply
853
+ // sent through the CLI fallback — e.g. inside a daemon-restart window — never
854
+ // armed, so the worker idled to the unarmed bound and stalled its FIFO). Same
855
+ // hook the daemon path uses; ONLY on
856
856
  // an ok outcome, errors swallowed (arming is best-effort, never fails the send).
857
857
  try {
858
858
  makeArmEphemeralOnDelivered(cfg)(caller)
@@ -925,7 +925,7 @@ const USAGE = `usage: iapeer <verb> [args]
925
925
  it up on the peer's first message); always-on: launchctl bootstrap. --all = every registered peer
926
926
  remove <peer> [--force] delete a peer's registry record (locked writer); refuses a LIVE peer unless --force
927
927
  send <target> (--message <text> | --message-file <f|->) [--from <id>] [--attachment <p>]… [--topic <t>] manual IAP send (fallback)
928
- <runtime> launch the cwd's peer (ALWAYS fresh)
928
+ <runtime> launch the cwd's peer FRESH; on a TTY drop into it (like attach), else detached
929
929
  connect telegram <peer> [--token <t>] attach a telegram bot to a peer (bot add → interface → router restart; asks only the token)
930
930
  enable <plugin> [peer] [--no-setup] install + enable an agfpd capability for a peer
931
931
  new <peer> [runtime] UNCONDITIONAL fresh restart: canary-clean kill + fresh wake (emergency lever for a hung/dead session — bypasses the peer; exit 0 = fresh session up+ready)
@@ -976,7 +976,7 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
976
976
  out(r.noop ? 'onboard: no marketplace changes (already configured / dry-run)\n' : 'onboard: marketplace(s) registered\n')
977
977
  let infraFailed = false
978
978
  const infra = typeof flags.infra === 'string' ? flags.infra.split(',').map(s => s.trim()).filter(Boolean) : []
979
- // Backbone default-yes steps (design «Onboard костяка», FINAL 10.06). ORDER is
979
+ // Backbone default-yes steps (design «Onboard костяка»). ORDER is
980
980
  // significant: notifier → TELEGRAM (creates the human peer) → memory below
981
981
  // (its --human resolves from the natural peer that just appeared). Each step
982
982
  // is soft-skip on unavailability; only a REAL deploy/create break fails.
@@ -1025,7 +1025,7 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1025
1025
  } else if (infra.length) {
1026
1026
  out(`onboard --dry-run: would onboard infra runtimes: ${infra.join(', ')}\n`)
1027
1027
  }
1028
- // Memory slot (контракт «Слот памяти», 10.06): optional DEFAULT-YES install of
1028
+ // Memory slot (контракт «Слот памяти»): optional DEFAULT-YES install of
1029
1029
  // the default provider; its own init runs with INHERITED stdio (the provider
1030
1030
  // owns the install questions). The step is REPORT-ONLY for the exit code — an
1031
1031
  // empty slot is a valid state regardless of why.
@@ -1354,9 +1354,9 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1354
1354
  return 1
1355
1355
  }
1356
1356
  case 'start': {
1357
- // --all re-enables every REGISTERED peer (mirror of `stop --all` — the 11.06
1358
- // incident: bringing a stopped fleet back required a manual loop over ~25
1359
- // peers). Enumeration is the registry, so unregistered garbage (stray flag
1357
+ // --all re-enables every REGISTERED peer (mirror of `stop --all` — without
1358
+ // it, bringing a stopped fleet back required a manual loop over every
1359
+ // peer). Enumeration is the registry, so unregistered garbage (stray flag
1360
1360
  // files for identities no record claims) is never touched. NOTE: for warm
1361
1361
  // peers this clears the stop flag only — no session is launched; each peer
1362
1362
  // becomes wakeable and the daemon brings its session up on the first message.
@@ -1390,13 +1390,13 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1390
1390
  if (o.codexHooksTrust) {
1391
1391
  out(`codex hooks trust: ${o.codexHooksTrust}\n`)
1392
1392
  }
1393
- // Stale identity-keyed markers must die with the record (boris 10.06: a
1394
- // namesake newborn inherited a dead peer's .stopped → refused to wake).
1393
+ // Stale identity-keyed markers must die with the record (a namesake
1394
+ // newborn inherited a dead peer's .stopped → refused to wake).
1395
1395
  if (o.purgedState?.length) {
1396
1396
  out(`lifecycle state purged: ${o.purgedState.join(', ')}\n`)
1397
1397
  }
1398
1398
  // Deliberate: the registry reap never deletes user data — but SAY so, or
1399
- // the default-location peers leave silent orphan folders (boris 10.06).
1399
+ // the default-location peers leave silent orphan folders.
1400
1400
  if (o.cwd && existsSync(o.cwd)) {
1401
1401
  out(`folder kept: ${o.cwd} (remove never deletes peer data — \`rm -rf\` it yourself if it was a throwaway)\n`)
1402
1402
  }
@@ -1586,10 +1586,10 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1586
1586
  return await runAlwaysOn(positionals[0], positionals[1], process.cwd())
1587
1587
  }
1588
1588
  case 'self-done': {
1589
- // SILENT-FINISH self-call for an ephemeral worker (контракт ЖЦ §wake_policy;
1590
- // развилка boris 10.06): a worker whose task produced NOTHING to send must
1591
- // still release its M3 FIFO — but an EMPTY report would violate Артур's
1592
- // invariant «событие-всё-отфильтровано = тишина» (no empty wakes of the
1589
+ // SILENT-FINISH self-call for an ephemeral worker (контракт ЖЦ §wake_policy):
1590
+ // a worker whose task produced NOTHING to send must still release its M3
1591
+ // FIFO — but an EMPTY report would violate the invariant
1592
+ // «событие-всё-отфильтровано = тишина» (no empty wakes of the
1593
1593
  // target). This verb is the non-waking arm: it sets the worker's OWN
1594
1594
  // .ephemeral-armed (same marker the ok-outbound hook sets), so the quiet
1595
1595
  // window reaps it within seconds and the drain feeds the next task — nobody
@@ -1610,10 +1610,9 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1610
1610
  setEphemeralArmed(cfg, identity)
1611
1611
  // The ephemeral check keys on the peer's CANONICAL cwd (registry), NOT on
1612
1612
  // process.cwd(): the verb is invoked from wherever the agent's shell
1613
- // happens to be (scriber lives in the vault half the time), and a foreign
1614
- // cwd made this warning LIE — «marker is inert» on a genuinely ephemeral
1615
- // peer (live case scriber 11.06: the false warning sent doc/scriber down a
1616
- // wrong root-cause chase). The marker itself was never affected — it is
1613
+ // happens to be, and a foreign cwd made this warning LIE — «marker is
1614
+ // inert» on a genuinely ephemeral peer (the false warning sends the reader
1615
+ // down a wrong root-cause chase). The marker itself was never affected — it is
1617
1616
  // identity-keyed and supervise checks the SESSION's canonical cwd.
1618
1617
  const addr = parseSessionName(identity)!
1619
1618
  const canonicalCwd = findPeer(readPeersIndex({ env }), addr.personality)?.cwd ?? process.cwd()
@@ -1667,7 +1666,7 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1667
1666
  return 0
1668
1667
  }
1669
1668
  case 'compact': {
1670
- // Dialogue control (UX directive 12.06): if the session is merely asleep
1669
+ // Dialogue control: if the session is merely asleep
1671
1670
  // after a clean idle-reap, resume the same dialogue and compact it; if there
1672
1671
  // is no resumable dialogue, fail honestly instead of compacting a fresh one.
1673
1672
  if (!positionals[0]) return usage(errOut)
@@ -1736,36 +1735,8 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1736
1735
  return 1
1737
1736
  }
1738
1737
  out(`${r.woke ? 'woke + ' : ''}attaching ${r.identity}…\n`)
1739
- // Attach-window observability (killer-hunt 11.06: «была ли смерть под
1740
- // attach» was answerable only INDIRECTLY via wake cause=attach — i.e. only
1741
- // when the session was dead at attach time). Bracket the operator's client
1742
- // window in lifecycle.log: ev=attach at entry, ev=attach-end (with the tmux
1743
- // client's exit code) when the operator detaches or the server dies under
1744
- // the client. A death timestamp inside an attach…attach-end window now
1745
- // reads directly off the log.
1746
1738
  const attachCfg = loadLifecycleConfig(env)
1747
- appendLifecycleEvent(attachCfg.eventLogDir, { ev: 'attach', identity: r.identity, woke: String(r.woke) }, { env })
1748
- // SPAWN-FLIP Ф0b-3: a supervisor-HOSTED session has no tmux to attach — hand the operator to
1749
- // the supervisor client (runSupervisorClient: raw passthrough + repaint-on-attach + Ctrl-]
1750
- // detach + both reattach port-deps). It calls process.exit on every terminal path, so bracket
1751
- // attach-end via an exit hook (appendFileSync is signal/exit-safe). Flag-off → tmux attach.
1752
- if (hostSessionAlive(r.identity)) {
1753
- process.on('exit', () =>
1754
- appendLifecycleEvent(attachCfg.eventLogDir, { ev: 'attach-end', identity: r.identity, rc: process.exitCode ?? 0 }, { env }),
1755
- )
1756
- await runSupervisorClient(hostRunDir(), r.identity)
1757
- return 0 // unreachable — runSupervisorClient exits on detach / session end
1758
- }
1759
- // Drop the operator into the session. `env -u TMUX` so a nested attach from
1760
- // inside tmux does not error ("sessions should be nested with care").
1761
- const attachEnv = { ...env }
1762
- delete attachEnv.TMUX
1763
- const a = spawnSync('tmux', ['-S', r.socketPath, 'attach', '-t', r.identity], {
1764
- stdio: 'inherit',
1765
- env: attachEnv as Record<string, string>,
1766
- })
1767
- appendLifecycleEvent(attachCfg.eventLogDir, { ev: 'attach-end', identity: r.identity, rc: a.status ?? -1 }, { env })
1768
- return a.status ?? 0
1739
+ return await attachIntoSession(r.identity, r.socketPath, env, attachCfg.eventLogDir, r.woke)
1769
1740
  }
1770
1741
  case 'shadow': {
1771
1742
  // Read-only fidelity OBSERVER for the tmux→pty migration burn-in (track «b»). Compares
@@ -1824,14 +1795,25 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
1824
1795
  return await runSupervisorCli(rest)
1825
1796
  }
1826
1797
  default: {
1827
- // `iapeer <runtime>` (launch) — folder-launch the cwd's peer, ALWAYS fresh.
1798
+ // `iapeer <runtime>` (launch) — folder-launch the cwd's peer, ALWAYS fresh. On a TTY this is
1799
+ // the human "start a fresh session and work in it" verb (parallel to `attach`, which resumes):
1800
+ // after a successful fresh bring-up it drops the operator straight into the new session.
1801
+ // Non-TTY (scripted / piped) keeps the fire-and-forget behavior — report the launch and exit.
1828
1802
  if (verb && isRuntime(verb)) {
1829
- const r = await folderLaunch({ cwd: process.cwd(), runtime: verb, env })
1803
+ const cfg = loadLifecycleConfig(env)
1804
+ const id = resolveIdentity({ env })
1805
+ const r = await folderLaunch({ cwd: process.cwd(), runtime: verb, env, cfg })
1830
1806
  if (r.status === 'FAILED') {
1831
1807
  errOut(`launch: ${r.reason}\n`)
1832
1808
  return 1
1833
1809
  }
1834
- out(`launched ${r.process_address} (fresh)\n`)
1810
+ const identity = r.process_address ?? buildProcessAddress(verb, id.personality)
1811
+ if (process.stdin.isTTY && process.stdout.isTTY) {
1812
+ const socketPath = buildSocketPath(verb, id.personality, cfg.sockDir)
1813
+ out(`launched ${identity} (fresh) — attaching…\n`)
1814
+ return await attachIntoSession(identity, socketPath, env, cfg.eventLogDir, true)
1815
+ }
1816
+ out(`launched ${identity} (fresh)\n`)
1835
1817
  return 0
1836
1818
  }
1837
1819
  return usage(errOut)
@@ -1854,6 +1836,41 @@ function defaultFromIdentity(env: NodeJS.ProcessEnv): string {
1854
1836
  return resolveIdentity({ env }).address
1855
1837
  }
1856
1838
 
1839
+ /** Drop the operator into a live peer session — the interactive open shared by `attach` (resume)
1840
+ * and a TTY `iapeer <runtime>` (fresh launch). A supervisor-HOSTED session has no tmux to attach,
1841
+ * so the operator is handed to the supervisor client (raw passthrough + repaint-on-attach + Ctrl-]
1842
+ * detach); otherwise `tmux attach`. The operator window is bracketed in lifecycle.log
1843
+ * (ev=attach … ev=attach-end) so a death timestamp inside the window reads directly off the log.
1844
+ * Returns the client exit code. */
1845
+ async function attachIntoSession(
1846
+ identity: string,
1847
+ socketPath: string,
1848
+ env: NodeJS.ProcessEnv,
1849
+ eventLogDir: string,
1850
+ woke: boolean,
1851
+ ): Promise<number> {
1852
+ appendLifecycleEvent(eventLogDir, { ev: 'attach', identity, woke: String(woke) }, { env })
1853
+ if (hostSessionAlive(identity)) {
1854
+ // runSupervisorClient calls process.exit on every terminal path → bracket attach-end via an
1855
+ // exit hook (appendFileSync is signal/exit-safe).
1856
+ process.on('exit', () =>
1857
+ appendLifecycleEvent(eventLogDir, { ev: 'attach-end', identity, rc: process.exitCode ?? 0 }, { env }),
1858
+ )
1859
+ await runSupervisorClient(hostRunDir(), identity)
1860
+ return 0 // unreachable — runSupervisorClient exits on detach / session end
1861
+ }
1862
+ // `env -u TMUX` so a nested attach from inside tmux does not error ("sessions should be nested
1863
+ // with care").
1864
+ const attachEnv = { ...env }
1865
+ delete attachEnv.TMUX
1866
+ const a = spawnSync('tmux', ['-S', socketPath, 'attach', '-t', identity], {
1867
+ stdio: 'inherit',
1868
+ env: attachEnv as Record<string, string>,
1869
+ })
1870
+ appendLifecycleEvent(eventLogDir, { ev: 'attach-end', identity, rc: a.status ?? -1 }, { env })
1871
+ return a.status ?? 0
1872
+ }
1873
+
1857
1874
  if (import.meta.main) {
1858
1875
  runCli(process.argv.slice(2)).then(code => process.exit(code))
1859
1876
  }
@@ -1,5 +1,5 @@
1
- // connect — per-peer channel attachment in ONE flow (design «Onboard костяка» §(в),
2
- // FINAL 10.06; flow facts confirmed by the telegram-runtime owner against v0.10.3).
1
+ // connect — per-peer channel attachment in ONE flow (design «Onboard костяка» §(в);
2
+ // flow facts confirmed by the telegram-runtime owner against v0.10.3).
3
3
  // Namespace: `iapeer connect <channel> <peer>` — extensible to future channels;
4
4
  // v1 implements `connect telegram <peer> [--token <t>]`.
5
5
  //
@@ -184,8 +184,8 @@ export async function connectTelegram(opts: ConnectTelegramOptions): Promise<Con
184
184
  return { state: 'bot-add-failed', peer, detail: (add.stderr || add.stdout || `exit ${add.status}`).trim() }
185
185
  }
186
186
  // @username: the bots/<alias>/.env TELEGRAM_BOT_USERNAME field is the RELIABLE
187
- // source (present on the live host; survives a quiet bot-add stdout — boris's
188
- // acceptance saw the activation line degrade to the BotFather hint). stdout
187
+ // source (present on the live host; survives a quiet bot-add stdout — acceptance
188
+ // testing saw the activation line degrade to the BotFather hint). stdout
189
189
  // match stays as the fallback.
190
190
  const envAfterAdd = readBotEnv(alias, env)
191
191
  const envUser = envAfterAdd?.match(/^TELEGRAM_BOT_USERNAME=(.+)$/m)?.[1]?.trim()