opensteer 0.5.4 → 0.5.5
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/CHANGELOG.md +4 -0
- package/README.md +2 -0
- package/bin/opensteer.mjs +163 -38
- package/dist/cli/server.cjs +41 -15
- package/dist/cli/server.js +41 -15
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
health checks to remove startup races across concurrent commands.
|
|
15
15
|
- Added strict in-daemon request serialization for session commands, while
|
|
16
16
|
keeping `ping` out of the queue for reliable liveness checks.
|
|
17
|
+
- Breaking: CLI daemon routing is now scoped by canonical `cwd`
|
|
18
|
+
(`realpath(cwd)`) + logical session (`--session`/`OPENSTEER_SESSION`) rather
|
|
19
|
+
than machine-wide session id matching; the same logical session can run in
|
|
20
|
+
parallel across different directories.
|
|
17
21
|
- Breaking: removed legacy `ai` config from `OpensteerConfig`; use top-level `model` instead.
|
|
18
22
|
- Breaking: `OPENSTEER_AI_MODEL` is no longer supported; use `OPENSTEER_MODEL`.
|
|
19
23
|
- Breaking: `OPENSTEER_RUNTIME` is no longer supported; use `OPENSTEER_MODE`.
|
package/README.md
CHANGED
|
@@ -111,6 +111,8 @@ opensteer close --session demo
|
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
For non-interactive runs, set `OPENSTEER_SESSION` or `OPENSTEER_CLIENT_ID`.
|
|
114
|
+
Runtime daemon routing for `OPENSTEER_SESSION` is scoped by canonical `cwd`
|
|
115
|
+
(`realpath(cwd)`) + logical session id.
|
|
114
116
|
|
|
115
117
|
## For AI Agents
|
|
116
118
|
|
package/bin/opensteer.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
closeSync,
|
|
7
7
|
existsSync,
|
|
8
8
|
openSync,
|
|
9
|
+
realpathSync,
|
|
9
10
|
readFileSync,
|
|
10
11
|
readdirSync,
|
|
11
12
|
unlinkSync,
|
|
@@ -55,11 +56,13 @@ const RUNTIME_PREFIX = 'opensteer-'
|
|
|
55
56
|
const SOCKET_SUFFIX = '.sock'
|
|
56
57
|
const PID_SUFFIX = '.pid'
|
|
57
58
|
const LOCK_SUFFIX = '.lock'
|
|
59
|
+
const METADATA_SUFFIX = '.meta.json'
|
|
58
60
|
const CLIENT_BINDING_PREFIX = `${RUNTIME_PREFIX}client-`
|
|
59
61
|
const CLIENT_BINDING_SUFFIX = '.session'
|
|
60
62
|
const CLOSE_ALL_REQUEST = { id: 1, command: 'close', args: {} }
|
|
61
63
|
const PING_REQUEST = { id: 1, command: 'ping', args: {} }
|
|
62
64
|
const SESSION_ID_PATTERN = /^[a-zA-Z0-9_-]+$/
|
|
65
|
+
const RUNTIME_SESSION_PREFIX = 'sc-'
|
|
63
66
|
|
|
64
67
|
function getVersion() {
|
|
65
68
|
try {
|
|
@@ -214,7 +217,20 @@ function isInteractiveTerminal() {
|
|
|
214
217
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
215
218
|
}
|
|
216
219
|
|
|
217
|
-
function
|
|
220
|
+
function resolveScopeDir() {
|
|
221
|
+
const cwd = process.cwd()
|
|
222
|
+
try {
|
|
223
|
+
return realpathSync(cwd)
|
|
224
|
+
} catch {
|
|
225
|
+
return cwd
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function buildRuntimeSession(scopeDir, logicalSession) {
|
|
230
|
+
return `${RUNTIME_SESSION_PREFIX}${hashKey(`${scopeDir}:${logicalSession}`).slice(0, 24)}`
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function resolveSession(flags, scopeDir) {
|
|
218
234
|
if (flags.session !== undefined) {
|
|
219
235
|
if (flags.session === true) {
|
|
220
236
|
throw new Error('--session requires a session id value.')
|
|
@@ -244,7 +260,7 @@ function resolveSession(flags) {
|
|
|
244
260
|
process.env.OPENSTEER_CLIENT_ID.trim().length > 0
|
|
245
261
|
) {
|
|
246
262
|
const clientId = process.env.OPENSTEER_CLIENT_ID.trim()
|
|
247
|
-
const clientKey = `client:${
|
|
263
|
+
const clientKey = `client:${scopeDir}:${clientId}`
|
|
248
264
|
const bound = readClientBinding(clientKey)
|
|
249
265
|
if (bound) {
|
|
250
266
|
return { session: bound, source: 'client_binding' }
|
|
@@ -256,7 +272,7 @@ function resolveSession(flags) {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
if (isInteractiveTerminal()) {
|
|
259
|
-
const ttyKey = `tty:${
|
|
275
|
+
const ttyKey = `tty:${scopeDir}:${process.ppid}`
|
|
260
276
|
const bound = readClientBinding(ttyKey)
|
|
261
277
|
if (bound) {
|
|
262
278
|
return { session: bound, source: 'tty_default' }
|
|
@@ -284,6 +300,10 @@ function getLockPath(session) {
|
|
|
284
300
|
return join(tmpdir(), `${RUNTIME_PREFIX}${session}${LOCK_SUFFIX}`)
|
|
285
301
|
}
|
|
286
302
|
|
|
303
|
+
function getMetadataPath(session) {
|
|
304
|
+
return join(tmpdir(), `${RUNTIME_PREFIX}${session}${METADATA_SUFFIX}`)
|
|
305
|
+
}
|
|
306
|
+
|
|
287
307
|
function buildRequest(command, flags, positional) {
|
|
288
308
|
const id = 1
|
|
289
309
|
const globalFlags = {}
|
|
@@ -430,20 +450,80 @@ function cleanStaleFiles(session, options = {}) {
|
|
|
430
450
|
unlinkSync(getPidPath(session))
|
|
431
451
|
} catch { }
|
|
432
452
|
}
|
|
453
|
+
|
|
454
|
+
try {
|
|
455
|
+
unlinkSync(getMetadataPath(session))
|
|
456
|
+
} catch { }
|
|
433
457
|
}
|
|
434
458
|
|
|
435
|
-
function startServer(
|
|
459
|
+
function startServer(runtimeSession, logicalSession, scopeDir) {
|
|
436
460
|
const child = spawn('node', [SERVER_SCRIPT], {
|
|
437
461
|
detached: true,
|
|
438
462
|
stdio: ['ignore', 'ignore', 'ignore'],
|
|
439
463
|
env: {
|
|
440
464
|
...process.env,
|
|
441
|
-
OPENSTEER_SESSION:
|
|
465
|
+
OPENSTEER_SESSION: runtimeSession,
|
|
466
|
+
OPENSTEER_LOGICAL_SESSION: logicalSession,
|
|
467
|
+
OPENSTEER_SCOPE_DIR: scopeDir,
|
|
442
468
|
},
|
|
443
469
|
})
|
|
444
470
|
child.unref()
|
|
445
471
|
}
|
|
446
472
|
|
|
473
|
+
function readMetadata(session) {
|
|
474
|
+
const metadataPath = getMetadataPath(session)
|
|
475
|
+
if (!existsSync(metadataPath)) {
|
|
476
|
+
return null
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
try {
|
|
480
|
+
const raw = JSON.parse(readFileSync(metadataPath, 'utf-8'))
|
|
481
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
482
|
+
return null
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (
|
|
486
|
+
typeof raw.logicalSession !== 'string' ||
|
|
487
|
+
!raw.logicalSession.trim() ||
|
|
488
|
+
typeof raw.scopeDir !== 'string' ||
|
|
489
|
+
!raw.scopeDir.trim() ||
|
|
490
|
+
typeof raw.runtimeSession !== 'string' ||
|
|
491
|
+
!raw.runtimeSession.trim()
|
|
492
|
+
) {
|
|
493
|
+
return null
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return {
|
|
497
|
+
logicalSession: raw.logicalSession.trim(),
|
|
498
|
+
scopeDir: raw.scopeDir,
|
|
499
|
+
runtimeSession: raw.runtimeSession.trim(),
|
|
500
|
+
createdAt:
|
|
501
|
+
typeof raw.createdAt === 'number' ? raw.createdAt : undefined,
|
|
502
|
+
updatedAt:
|
|
503
|
+
typeof raw.updatedAt === 'number' ? raw.updatedAt : undefined,
|
|
504
|
+
}
|
|
505
|
+
} catch {
|
|
506
|
+
return null
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function writeMetadata(runtimeSession, logicalSession, scopeDir) {
|
|
511
|
+
const metadataPath = getMetadataPath(runtimeSession)
|
|
512
|
+
const existing = readMetadata(runtimeSession)
|
|
513
|
+
const now = Date.now()
|
|
514
|
+
const payload = {
|
|
515
|
+
runtimeSession,
|
|
516
|
+
logicalSession,
|
|
517
|
+
scopeDir,
|
|
518
|
+
createdAt: existing?.createdAt ?? now,
|
|
519
|
+
updatedAt: now,
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
try {
|
|
523
|
+
writeFileSync(metadataPath, JSON.stringify(payload, null, 2))
|
|
524
|
+
} catch { }
|
|
525
|
+
}
|
|
526
|
+
|
|
447
527
|
function sendCommand(socketPath, request, timeoutMs = RESPONSE_TIMEOUT) {
|
|
448
528
|
return new Promise((resolve, reject) => {
|
|
449
529
|
const socket = connect(socketPath)
|
|
@@ -606,8 +686,14 @@ async function waitForServerReady(session, timeout) {
|
|
|
606
686
|
throw new Error(`Timed out waiting for server '${session}' to become healthy.`)
|
|
607
687
|
}
|
|
608
688
|
|
|
609
|
-
async function ensureServer(
|
|
610
|
-
|
|
689
|
+
async function ensureServer(context) {
|
|
690
|
+
const runtimeSession = context.runtimeSession
|
|
691
|
+
if (await isServerHealthy(runtimeSession)) {
|
|
692
|
+
writeMetadata(
|
|
693
|
+
runtimeSession,
|
|
694
|
+
context.logicalSession,
|
|
695
|
+
context.scopeDir
|
|
696
|
+
)
|
|
611
697
|
return
|
|
612
698
|
}
|
|
613
699
|
|
|
@@ -620,31 +706,45 @@ async function ensureServer(session) {
|
|
|
620
706
|
const deadline = Date.now() + CONNECT_TIMEOUT
|
|
621
707
|
|
|
622
708
|
while (Date.now() < deadline) {
|
|
623
|
-
if (await isServerHealthy(
|
|
709
|
+
if (await isServerHealthy(runtimeSession)) {
|
|
710
|
+
writeMetadata(
|
|
711
|
+
runtimeSession,
|
|
712
|
+
context.logicalSession,
|
|
713
|
+
context.scopeDir
|
|
714
|
+
)
|
|
624
715
|
return
|
|
625
716
|
}
|
|
626
717
|
|
|
627
|
-
const existingPid = readPid(getPidPath(
|
|
718
|
+
const existingPid = readPid(getPidPath(runtimeSession))
|
|
628
719
|
if (existingPid && isPidAlive(existingPid)) {
|
|
629
720
|
await sleep(POLL_INTERVAL)
|
|
630
721
|
continue
|
|
631
722
|
}
|
|
632
723
|
|
|
633
|
-
recoverStaleStartLock(
|
|
724
|
+
recoverStaleStartLock(runtimeSession)
|
|
634
725
|
|
|
635
|
-
if (acquireStartLock(
|
|
726
|
+
if (acquireStartLock(runtimeSession)) {
|
|
636
727
|
try {
|
|
637
|
-
if (!(await isServerHealthy(
|
|
638
|
-
startServer(
|
|
728
|
+
if (!(await isServerHealthy(runtimeSession))) {
|
|
729
|
+
startServer(
|
|
730
|
+
runtimeSession,
|
|
731
|
+
context.logicalSession,
|
|
732
|
+
context.scopeDir
|
|
733
|
+
)
|
|
639
734
|
}
|
|
640
735
|
|
|
641
736
|
await waitForServerReady(
|
|
642
|
-
|
|
737
|
+
runtimeSession,
|
|
643
738
|
Math.max(500, deadline - Date.now())
|
|
644
739
|
)
|
|
740
|
+
writeMetadata(
|
|
741
|
+
runtimeSession,
|
|
742
|
+
context.logicalSession,
|
|
743
|
+
context.scopeDir
|
|
744
|
+
)
|
|
645
745
|
return
|
|
646
746
|
} finally {
|
|
647
|
-
releaseStartLock(
|
|
747
|
+
releaseStartLock(runtimeSession)
|
|
648
748
|
}
|
|
649
749
|
}
|
|
650
750
|
|
|
@@ -652,7 +752,7 @@ async function ensureServer(session) {
|
|
|
652
752
|
}
|
|
653
753
|
|
|
654
754
|
throw new Error(
|
|
655
|
-
`Failed to start server for session '${
|
|
755
|
+
`Failed to start server for session '${context.logicalSession}' in cwd scope '${context.scopeDir}' within ${CONNECT_TIMEOUT}ms.`
|
|
656
756
|
)
|
|
657
757
|
}
|
|
658
758
|
|
|
@@ -665,24 +765,39 @@ function listSessions() {
|
|
|
665
765
|
continue
|
|
666
766
|
}
|
|
667
767
|
|
|
668
|
-
const
|
|
768
|
+
const runtimeSession = entry.slice(
|
|
669
769
|
RUNTIME_PREFIX.length,
|
|
670
770
|
entry.length - PID_SUFFIX.length
|
|
671
771
|
)
|
|
672
|
-
if (!
|
|
772
|
+
if (!runtimeSession) {
|
|
673
773
|
continue
|
|
674
774
|
}
|
|
675
775
|
|
|
676
776
|
const pid = readPid(join(tmpdir(), entry))
|
|
677
777
|
if (!pid || !isPidAlive(pid)) {
|
|
678
|
-
cleanStaleFiles(
|
|
778
|
+
cleanStaleFiles(runtimeSession)
|
|
679
779
|
continue
|
|
680
780
|
}
|
|
681
781
|
|
|
682
|
-
|
|
782
|
+
const metadata = readMetadata(runtimeSession)
|
|
783
|
+
sessions.push({
|
|
784
|
+
name: metadata?.logicalSession || runtimeSession,
|
|
785
|
+
logicalSession: metadata?.logicalSession || runtimeSession,
|
|
786
|
+
runtimeSession,
|
|
787
|
+
scopeDir: metadata?.scopeDir || null,
|
|
788
|
+
pid,
|
|
789
|
+
})
|
|
683
790
|
}
|
|
684
791
|
|
|
685
|
-
sessions.sort((a, b) =>
|
|
792
|
+
sessions.sort((a, b) => {
|
|
793
|
+
const scopeA = a.scopeDir || ''
|
|
794
|
+
const scopeB = b.scopeDir || ''
|
|
795
|
+
if (scopeA !== scopeB) {
|
|
796
|
+
return scopeA.localeCompare(scopeB)
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return a.logicalSession.localeCompare(b.logicalSession)
|
|
800
|
+
})
|
|
686
801
|
return sessions
|
|
687
802
|
}
|
|
688
803
|
|
|
@@ -692,9 +807,9 @@ async function closeAllSessions() {
|
|
|
692
807
|
const failures = []
|
|
693
808
|
|
|
694
809
|
for (const session of sessions) {
|
|
695
|
-
const socketPath = getSocketPath(session.
|
|
810
|
+
const socketPath = getSocketPath(session.runtimeSession)
|
|
696
811
|
if (!existsSync(socketPath)) {
|
|
697
|
-
cleanStaleFiles(session.
|
|
812
|
+
cleanStaleFiles(session.runtimeSession)
|
|
698
813
|
continue
|
|
699
814
|
}
|
|
700
815
|
|
|
@@ -704,12 +819,12 @@ async function closeAllSessions() {
|
|
|
704
819
|
closed.push(session)
|
|
705
820
|
} else {
|
|
706
821
|
failures.push(
|
|
707
|
-
`${session.
|
|
822
|
+
`${session.logicalSession} (${session.scopeDir || 'unknown scope'}): ${response?.error || 'unknown close error'}`
|
|
708
823
|
)
|
|
709
824
|
}
|
|
710
825
|
} catch (err) {
|
|
711
826
|
failures.push(
|
|
712
|
-
`${session.
|
|
827
|
+
`${session.logicalSession} (${session.scopeDir || 'unknown scope'}): ${err instanceof Error ? err.message : String(err)}`
|
|
713
828
|
)
|
|
714
829
|
}
|
|
715
830
|
}
|
|
@@ -817,7 +932,7 @@ Navigation:
|
|
|
817
932
|
|
|
818
933
|
Sessions:
|
|
819
934
|
sessions List active session-scoped daemons
|
|
820
|
-
status Show resolved
|
|
935
|
+
status Show resolved logical/runtime session and session state
|
|
821
936
|
|
|
822
937
|
Observation:
|
|
823
938
|
snapshot [--mode action] Get page snapshot
|
|
@@ -868,7 +983,7 @@ Skills:
|
|
|
868
983
|
skills --help Show skills installer help
|
|
869
984
|
|
|
870
985
|
Global Flags:
|
|
871
|
-
--session <id>
|
|
986
|
+
--session <id> Logical session id (scoped by canonical cwd)
|
|
872
987
|
--name <namespace> Selector namespace for cache storage on 'open'
|
|
873
988
|
--headless Launch browser in headless mode
|
|
874
989
|
--connect-url <url> Connect to a running browser (e.g. http://localhost:9222)
|
|
@@ -881,7 +996,7 @@ Global Flags:
|
|
|
881
996
|
--version, -v Show version
|
|
882
997
|
|
|
883
998
|
Environment:
|
|
884
|
-
OPENSTEER_SESSION
|
|
999
|
+
OPENSTEER_SESSION Logical session id (equivalent to --session)
|
|
885
1000
|
OPENSTEER_CLIENT_ID Stable client identity for default session binding
|
|
886
1001
|
OPENSTEER_NAME Default selector namespace for 'open' when --name is omitted
|
|
887
1002
|
OPENSTEER_MODE Runtime routing: "local" (default) or "cloud"
|
|
@@ -925,27 +1040,37 @@ async function main() {
|
|
|
925
1040
|
|
|
926
1041
|
let resolvedSession
|
|
927
1042
|
let resolvedName
|
|
1043
|
+
const scopeDir = resolveScopeDir()
|
|
928
1044
|
try {
|
|
929
|
-
resolvedSession = resolveSession(flags)
|
|
1045
|
+
resolvedSession = resolveSession(flags, scopeDir)
|
|
930
1046
|
resolvedName = resolveName(flags, resolvedSession.session)
|
|
931
1047
|
} catch (err) {
|
|
932
1048
|
error(err instanceof Error ? err.message : 'Failed to resolve session')
|
|
933
1049
|
}
|
|
934
1050
|
|
|
935
|
-
const
|
|
1051
|
+
const logicalSession = resolvedSession.session
|
|
1052
|
+
const runtimeSession = buildRuntimeSession(scopeDir, logicalSession)
|
|
936
1053
|
const sessionSource = resolvedSession.source
|
|
937
1054
|
const name = resolvedName.name
|
|
938
1055
|
const nameSource = resolvedName.source
|
|
939
|
-
const socketPath = getSocketPath(
|
|
1056
|
+
const socketPath = getSocketPath(runtimeSession)
|
|
1057
|
+
const routingContext = {
|
|
1058
|
+
logicalSession,
|
|
1059
|
+
runtimeSession,
|
|
1060
|
+
scopeDir,
|
|
1061
|
+
}
|
|
940
1062
|
|
|
941
1063
|
if (command === 'status') {
|
|
942
1064
|
output({
|
|
943
1065
|
ok: true,
|
|
944
|
-
resolvedSession:
|
|
1066
|
+
resolvedSession: logicalSession,
|
|
1067
|
+
logicalSession,
|
|
1068
|
+
runtimeSession,
|
|
1069
|
+
scopeDir,
|
|
945
1070
|
sessionSource,
|
|
946
1071
|
resolvedName: name,
|
|
947
1072
|
nameSource,
|
|
948
|
-
serverRunning: await isServerHealthy(
|
|
1073
|
+
serverRunning: await isServerHealthy(runtimeSession),
|
|
949
1074
|
socketPath,
|
|
950
1075
|
sessions: listSessions(),
|
|
951
1076
|
})
|
|
@@ -961,20 +1086,20 @@ async function main() {
|
|
|
961
1086
|
request.args.name = name
|
|
962
1087
|
}
|
|
963
1088
|
|
|
964
|
-
if (!(await isServerHealthy(
|
|
1089
|
+
if (!(await isServerHealthy(runtimeSession))) {
|
|
965
1090
|
if (command !== 'open') {
|
|
966
1091
|
error(
|
|
967
|
-
`No server running for session '${
|
|
1092
|
+
`No server running for session '${logicalSession}' in cwd scope '${scopeDir}' (resolved from ${sessionSource}). Run 'opensteer open' first or use 'opensteer sessions' to see active sessions.`
|
|
968
1093
|
)
|
|
969
1094
|
}
|
|
970
1095
|
|
|
971
1096
|
try {
|
|
972
|
-
await ensureServer(
|
|
1097
|
+
await ensureServer(routingContext)
|
|
973
1098
|
} catch (err) {
|
|
974
1099
|
error(
|
|
975
1100
|
err instanceof Error
|
|
976
1101
|
? err.message
|
|
977
|
-
: `Failed to start server for session '${
|
|
1102
|
+
: `Failed to start server for session '${logicalSession}' in cwd scope '${scopeDir}'.`
|
|
978
1103
|
)
|
|
979
1104
|
}
|
|
980
1105
|
}
|
|
@@ -992,7 +1117,7 @@ async function main() {
|
|
|
992
1117
|
error(
|
|
993
1118
|
formatTransportFailure(
|
|
994
1119
|
err,
|
|
995
|
-
`Failed to run '${command}' for session '${
|
|
1120
|
+
`Failed to run '${command}' for session '${logicalSession}' in cwd scope '${scopeDir}'`
|
|
996
1121
|
)
|
|
997
1122
|
)
|
|
998
1123
|
}
|
package/dist/cli/server.cjs
CHANGED
|
@@ -12605,6 +12605,9 @@ function getSocketPath(session2) {
|
|
|
12605
12605
|
function getPidPath(session2) {
|
|
12606
12606
|
return (0, import_path6.join)((0, import_os2.tmpdir)(), `${prefix(session2)}.pid`);
|
|
12607
12607
|
}
|
|
12608
|
+
function getMetadataPath(session2) {
|
|
12609
|
+
return (0, import_path6.join)((0, import_os2.tmpdir)(), `${prefix(session2)}.meta.json`);
|
|
12610
|
+
}
|
|
12608
12611
|
|
|
12609
12612
|
// src/cli/commands.ts
|
|
12610
12613
|
var import_promises2 = require("fs/promises");
|
|
@@ -12873,6 +12876,8 @@ if (!sessionEnv) {
|
|
|
12873
12876
|
process.exit(1);
|
|
12874
12877
|
}
|
|
12875
12878
|
var session = sessionEnv;
|
|
12879
|
+
var logicalSession = process.env.OPENSTEER_LOGICAL_SESSION?.trim() || session;
|
|
12880
|
+
var scopeDir = process.env.OPENSTEER_SCOPE_DIR?.trim() || process.cwd();
|
|
12876
12881
|
var socketPath = getSocketPath(session);
|
|
12877
12882
|
var pidPath = getPidPath(session);
|
|
12878
12883
|
function cleanup() {
|
|
@@ -12884,6 +12889,10 @@ function cleanup() {
|
|
|
12884
12889
|
(0, import_fs4.unlinkSync)(pidPath);
|
|
12885
12890
|
} catch {
|
|
12886
12891
|
}
|
|
12892
|
+
try {
|
|
12893
|
+
(0, import_fs4.unlinkSync)(getMetadataPath(session));
|
|
12894
|
+
} catch {
|
|
12895
|
+
}
|
|
12887
12896
|
}
|
|
12888
12897
|
function beginShutdown() {
|
|
12889
12898
|
if (shuttingDown) return;
|
|
@@ -12925,10 +12934,15 @@ async function handleRequest(request, socket) {
|
|
|
12925
12934
|
sendResponse(socket, {
|
|
12926
12935
|
id,
|
|
12927
12936
|
ok: false,
|
|
12928
|
-
error: `Session '${
|
|
12937
|
+
error: `Session '${logicalSession}' is shutting down.`,
|
|
12929
12938
|
errorInfo: {
|
|
12930
|
-
message: `Session '${
|
|
12931
|
-
code: "SESSION_SHUTTING_DOWN"
|
|
12939
|
+
message: `Session '${logicalSession}' is shutting down.`,
|
|
12940
|
+
code: "SESSION_SHUTTING_DOWN",
|
|
12941
|
+
details: {
|
|
12942
|
+
session: logicalSession,
|
|
12943
|
+
runtimeSession: session,
|
|
12944
|
+
scopeDir
|
|
12945
|
+
}
|
|
12932
12946
|
}
|
|
12933
12947
|
});
|
|
12934
12948
|
return;
|
|
@@ -12937,10 +12951,15 @@ async function handleRequest(request, socket) {
|
|
|
12937
12951
|
sendResponse(socket, {
|
|
12938
12952
|
id,
|
|
12939
12953
|
ok: false,
|
|
12940
|
-
error: `Session '${
|
|
12954
|
+
error: `Session '${logicalSession}' is shutting down. Retry your command.`,
|
|
12941
12955
|
errorInfo: {
|
|
12942
|
-
message: `Session '${
|
|
12943
|
-
code: "SESSION_SHUTTING_DOWN"
|
|
12956
|
+
message: `Session '${logicalSession}' is shutting down. Retry your command.`,
|
|
12957
|
+
code: "SESSION_SHUTTING_DOWN",
|
|
12958
|
+
details: {
|
|
12959
|
+
session: logicalSession,
|
|
12960
|
+
runtimeSession: session,
|
|
12961
|
+
scopeDir
|
|
12962
|
+
}
|
|
12944
12963
|
}
|
|
12945
12964
|
});
|
|
12946
12965
|
return;
|
|
@@ -12957,12 +12976,14 @@ async function handleRequest(request, socket) {
|
|
|
12957
12976
|
sendResponse(socket, {
|
|
12958
12977
|
id,
|
|
12959
12978
|
ok: false,
|
|
12960
|
-
error: `Session '${
|
|
12979
|
+
error: `Session '${logicalSession}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
12961
12980
|
errorInfo: {
|
|
12962
|
-
message: `Session '${
|
|
12981
|
+
message: `Session '${logicalSession}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
12963
12982
|
code: "SESSION_NAMESPACE_MISMATCH",
|
|
12964
12983
|
details: {
|
|
12965
|
-
session,
|
|
12984
|
+
session: logicalSession,
|
|
12985
|
+
runtimeSession: session,
|
|
12986
|
+
scopeDir,
|
|
12966
12987
|
activeNamespace: selectorNamespace,
|
|
12967
12988
|
requestedNamespace: requestedName
|
|
12968
12989
|
}
|
|
@@ -12971,9 +12992,9 @@ async function handleRequest(request, socket) {
|
|
|
12971
12992
|
return;
|
|
12972
12993
|
}
|
|
12973
12994
|
if (!selectorNamespace) {
|
|
12974
|
-
selectorNamespace = requestedName ??
|
|
12995
|
+
selectorNamespace = requestedName ?? logicalSession;
|
|
12975
12996
|
}
|
|
12976
|
-
const activeNamespace = selectorNamespace ??
|
|
12997
|
+
const activeNamespace = selectorNamespace ?? logicalSession;
|
|
12977
12998
|
if (instance && !launchPromise) {
|
|
12978
12999
|
try {
|
|
12979
13000
|
if (instance.page.isClosed()) {
|
|
@@ -13017,7 +13038,10 @@ async function handleRequest(request, socket) {
|
|
|
13017
13038
|
ok: true,
|
|
13018
13039
|
result: {
|
|
13019
13040
|
url: instance.page.url(),
|
|
13020
|
-
session,
|
|
13041
|
+
session: logicalSession,
|
|
13042
|
+
logicalSession,
|
|
13043
|
+
runtimeSession: session,
|
|
13044
|
+
scopeDir,
|
|
13021
13045
|
name: activeNamespace,
|
|
13022
13046
|
cloudSessionId: instance.getCloudSessionId() ?? void 0,
|
|
13023
13047
|
cloudSessionUrl: instance.getCloudSessionUrl() ?? void 0
|
|
@@ -13059,12 +13083,14 @@ async function handleRequest(request, socket) {
|
|
|
13059
13083
|
sendResponse(socket, {
|
|
13060
13084
|
id,
|
|
13061
13085
|
ok: false,
|
|
13062
|
-
error: `No browser session in session '${
|
|
13086
|
+
error: `No browser session in session '${logicalSession}' (scope '${scopeDir}'). Call 'opensteer open --session ${logicalSession}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
13063
13087
|
errorInfo: {
|
|
13064
|
-
message: `No browser session in session '${
|
|
13088
|
+
message: `No browser session in session '${logicalSession}' (scope '${scopeDir}'). Call 'opensteer open --session ${logicalSession}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
13065
13089
|
code: "SESSION_NOT_OPEN",
|
|
13066
13090
|
details: {
|
|
13067
|
-
session
|
|
13091
|
+
session: logicalSession,
|
|
13092
|
+
runtimeSession: session,
|
|
13093
|
+
scopeDir
|
|
13068
13094
|
}
|
|
13069
13095
|
}
|
|
13070
13096
|
});
|
package/dist/cli/server.js
CHANGED
|
@@ -20,6 +20,9 @@ function getSocketPath(session2) {
|
|
|
20
20
|
function getPidPath(session2) {
|
|
21
21
|
return join(tmpdir(), `${prefix(session2)}.pid`);
|
|
22
22
|
}
|
|
23
|
+
function getMetadataPath(session2) {
|
|
24
|
+
return join(tmpdir(), `${prefix(session2)}.meta.json`);
|
|
25
|
+
}
|
|
23
26
|
|
|
24
27
|
// src/cli/commands.ts
|
|
25
28
|
import { writeFile } from "fs/promises";
|
|
@@ -288,6 +291,8 @@ if (!sessionEnv) {
|
|
|
288
291
|
process.exit(1);
|
|
289
292
|
}
|
|
290
293
|
var session = sessionEnv;
|
|
294
|
+
var logicalSession = process.env.OPENSTEER_LOGICAL_SESSION?.trim() || session;
|
|
295
|
+
var scopeDir = process.env.OPENSTEER_SCOPE_DIR?.trim() || process.cwd();
|
|
291
296
|
var socketPath = getSocketPath(session);
|
|
292
297
|
var pidPath = getPidPath(session);
|
|
293
298
|
function cleanup() {
|
|
@@ -299,6 +304,10 @@ function cleanup() {
|
|
|
299
304
|
unlinkSync(pidPath);
|
|
300
305
|
} catch {
|
|
301
306
|
}
|
|
307
|
+
try {
|
|
308
|
+
unlinkSync(getMetadataPath(session));
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
302
311
|
}
|
|
303
312
|
function beginShutdown() {
|
|
304
313
|
if (shuttingDown) return;
|
|
@@ -340,10 +349,15 @@ async function handleRequest(request, socket) {
|
|
|
340
349
|
sendResponse(socket, {
|
|
341
350
|
id,
|
|
342
351
|
ok: false,
|
|
343
|
-
error: `Session '${
|
|
352
|
+
error: `Session '${logicalSession}' is shutting down.`,
|
|
344
353
|
errorInfo: {
|
|
345
|
-
message: `Session '${
|
|
346
|
-
code: "SESSION_SHUTTING_DOWN"
|
|
354
|
+
message: `Session '${logicalSession}' is shutting down.`,
|
|
355
|
+
code: "SESSION_SHUTTING_DOWN",
|
|
356
|
+
details: {
|
|
357
|
+
session: logicalSession,
|
|
358
|
+
runtimeSession: session,
|
|
359
|
+
scopeDir
|
|
360
|
+
}
|
|
347
361
|
}
|
|
348
362
|
});
|
|
349
363
|
return;
|
|
@@ -352,10 +366,15 @@ async function handleRequest(request, socket) {
|
|
|
352
366
|
sendResponse(socket, {
|
|
353
367
|
id,
|
|
354
368
|
ok: false,
|
|
355
|
-
error: `Session '${
|
|
369
|
+
error: `Session '${logicalSession}' is shutting down. Retry your command.`,
|
|
356
370
|
errorInfo: {
|
|
357
|
-
message: `Session '${
|
|
358
|
-
code: "SESSION_SHUTTING_DOWN"
|
|
371
|
+
message: `Session '${logicalSession}' is shutting down. Retry your command.`,
|
|
372
|
+
code: "SESSION_SHUTTING_DOWN",
|
|
373
|
+
details: {
|
|
374
|
+
session: logicalSession,
|
|
375
|
+
runtimeSession: session,
|
|
376
|
+
scopeDir
|
|
377
|
+
}
|
|
359
378
|
}
|
|
360
379
|
});
|
|
361
380
|
return;
|
|
@@ -372,12 +391,14 @@ async function handleRequest(request, socket) {
|
|
|
372
391
|
sendResponse(socket, {
|
|
373
392
|
id,
|
|
374
393
|
ok: false,
|
|
375
|
-
error: `Session '${
|
|
394
|
+
error: `Session '${logicalSession}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
376
395
|
errorInfo: {
|
|
377
|
-
message: `Session '${
|
|
396
|
+
message: `Session '${logicalSession}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
378
397
|
code: "SESSION_NAMESPACE_MISMATCH",
|
|
379
398
|
details: {
|
|
380
|
-
session,
|
|
399
|
+
session: logicalSession,
|
|
400
|
+
runtimeSession: session,
|
|
401
|
+
scopeDir,
|
|
381
402
|
activeNamespace: selectorNamespace,
|
|
382
403
|
requestedNamespace: requestedName
|
|
383
404
|
}
|
|
@@ -386,9 +407,9 @@ async function handleRequest(request, socket) {
|
|
|
386
407
|
return;
|
|
387
408
|
}
|
|
388
409
|
if (!selectorNamespace) {
|
|
389
|
-
selectorNamespace = requestedName ??
|
|
410
|
+
selectorNamespace = requestedName ?? logicalSession;
|
|
390
411
|
}
|
|
391
|
-
const activeNamespace = selectorNamespace ??
|
|
412
|
+
const activeNamespace = selectorNamespace ?? logicalSession;
|
|
392
413
|
if (instance && !launchPromise) {
|
|
393
414
|
try {
|
|
394
415
|
if (instance.page.isClosed()) {
|
|
@@ -432,7 +453,10 @@ async function handleRequest(request, socket) {
|
|
|
432
453
|
ok: true,
|
|
433
454
|
result: {
|
|
434
455
|
url: instance.page.url(),
|
|
435
|
-
session,
|
|
456
|
+
session: logicalSession,
|
|
457
|
+
logicalSession,
|
|
458
|
+
runtimeSession: session,
|
|
459
|
+
scopeDir,
|
|
436
460
|
name: activeNamespace,
|
|
437
461
|
cloudSessionId: instance.getCloudSessionId() ?? void 0,
|
|
438
462
|
cloudSessionUrl: instance.getCloudSessionUrl() ?? void 0
|
|
@@ -474,12 +498,14 @@ async function handleRequest(request, socket) {
|
|
|
474
498
|
sendResponse(socket, {
|
|
475
499
|
id,
|
|
476
500
|
ok: false,
|
|
477
|
-
error: `No browser session in session '${
|
|
501
|
+
error: `No browser session in session '${logicalSession}' (scope '${scopeDir}'). Call 'opensteer open --session ${logicalSession}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
478
502
|
errorInfo: {
|
|
479
|
-
message: `No browser session in session '${
|
|
503
|
+
message: `No browser session in session '${logicalSession}' (scope '${scopeDir}'). Call 'opensteer open --session ${logicalSession}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
480
504
|
code: "SESSION_NOT_OPEN",
|
|
481
505
|
details: {
|
|
482
|
-
session
|
|
506
|
+
session: logicalSession,
|
|
507
|
+
runtimeSession: session,
|
|
508
|
+
scopeDir
|
|
483
509
|
}
|
|
484
510
|
}
|
|
485
511
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opensteer",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Open-source browser automation SDK
|
|
3
|
+
"version": "0.5.5",
|
|
4
|
+
"description": "Open-source browser automation SDK and CLI that lets AI agents build complex scrapers directly in your codebase.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|