@xmodelin/dsh-collab-sessions 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +17 -13
- package/index.js +17 -7
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -1971,22 +1971,26 @@ window.__ModuleLoader__.load({
|
|
|
1971
1971
|
.find(session => (session.retainedBy?.mainView ?? 0) > 0)
|
|
1972
1972
|
return main?.projectionValues?.agentPreset
|
|
1973
1973
|
}
|
|
1974
|
-
const originalOpenWorkspace = ctx.uiWorkspace.openWorkspace
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1974
|
+
const originalOpenWorkspace = typeof ctx.uiWorkspace.openWorkspace === 'function'
|
|
1975
|
+
? ctx.uiWorkspace.openWorkspace.bind(ctx.uiWorkspace)
|
|
1976
|
+
: undefined
|
|
1977
|
+
if (originalOpenWorkspace !== undefined) {
|
|
1978
|
+
const openWorkspacePreservingPreset = (workspaceId, beforeOpen, options) => {
|
|
1979
|
+
if (options === undefined) {
|
|
1980
|
+
const preset = mainSessionPreset()
|
|
1981
|
+
if (preset === 'collab' || preset === 'supervisor') {
|
|
1982
|
+
return originalOpenWorkspace(workspaceId, beforeOpen, { agentPreset: preset })
|
|
1983
|
+
}
|
|
1980
1984
|
}
|
|
1985
|
+
return originalOpenWorkspace(workspaceId, beforeOpen, options)
|
|
1981
1986
|
}
|
|
1982
|
-
|
|
1987
|
+
ctx.uiWorkspace.openWorkspace = openWorkspacePreservingPreset
|
|
1988
|
+
ctx.effect(() => () => {
|
|
1989
|
+
if (ctx.uiWorkspace.openWorkspace === openWorkspacePreservingPreset) {
|
|
1990
|
+
ctx.uiWorkspace.openWorkspace = originalOpenWorkspace
|
|
1991
|
+
}
|
|
1992
|
+
}, 'collab:workspace-switch-preset')
|
|
1983
1993
|
}
|
|
1984
|
-
ctx.uiWorkspace.openWorkspace = openWorkspacePreservingPreset
|
|
1985
|
-
ctx.effect(() => () => {
|
|
1986
|
-
if (ctx.uiWorkspace.openWorkspace === openWorkspacePreservingPreset) {
|
|
1987
|
-
ctx.uiWorkspace.openWorkspace = originalOpenWorkspace
|
|
1988
|
-
}
|
|
1989
|
-
}, 'collab:workspace-switch-preset')
|
|
1990
1994
|
|
|
1991
1995
|
const start = (preset = 'collab') => {
|
|
1992
1996
|
try {
|
package/index.js
CHANGED
|
@@ -1106,7 +1106,7 @@ export function apply(ctx, config = {}) {
|
|
|
1106
1106
|
|
|
1107
1107
|
/** Compact live capability lines injected into the supervisor prompt each turn. */
|
|
1108
1108
|
const capabilityRoster = (supervisor) => relationships.listForSupervisor(supervisor)
|
|
1109
|
-
.filter(relationship => relationship.offer === true)
|
|
1109
|
+
.filter(relationship => relationship.offer === true && isFunctionalWorker(relationship.worker))
|
|
1110
1110
|
.map(relationship => {
|
|
1111
1111
|
const capability = effectiveCapability(relationship)
|
|
1112
1112
|
const name = capability?.name ?? '(request-only)'
|
|
@@ -1116,8 +1116,10 @@ export function apply(ctx, config = {}) {
|
|
|
1116
1116
|
return `- ${relationship.worker} capability=${JSON.stringify(name)} source=${source} version=${version}${capability?.changed === true ? ' changed=yes' : ''}${description.length === 0 ? '' : ` description=${JSON.stringify(description.slice(0, 500))}`}`
|
|
1117
1117
|
})
|
|
1118
1118
|
|
|
1119
|
+
const isFunctionalWorker = (sessionId) => registry.get(sessionId)?.preset === PRESET
|
|
1120
|
+
|
|
1119
1121
|
const workerCandidates = (supervisor) => registry.list()
|
|
1120
|
-
.filter(entry => entry.sessionId !== supervisor && entry.preset
|
|
1122
|
+
.filter(entry => entry.sessionId !== supervisor && entry.preset === PRESET)
|
|
1121
1123
|
.map(entry => {
|
|
1122
1124
|
const capability = liveCapability(entry.sessionId)
|
|
1123
1125
|
return {
|
|
@@ -1299,6 +1301,7 @@ export function apply(ctx, config = {}) {
|
|
|
1299
1301
|
execute: (_args, exec) => {
|
|
1300
1302
|
const self = requireSupervisor(exec)
|
|
1301
1303
|
const relationshipsForSelf = relationships.listForSupervisor(self.sessionId)
|
|
1304
|
+
.filter(relationship => relationship.offer === true && isFunctionalWorker(relationship.worker))
|
|
1302
1305
|
if (relationshipsForSelf.length === 0) return 'No functional sessions are registered to this supervisor yet.'
|
|
1303
1306
|
const lines = [`supervisor: ${self.sessionId}`, '']
|
|
1304
1307
|
for (const relationship of relationshipsForSelf) {
|
|
@@ -1377,6 +1380,7 @@ export function apply(ctx, config = {}) {
|
|
|
1377
1380
|
if (relationship === undefined || relationship.offer !== true) {
|
|
1378
1381
|
throw new Error('worker is not registered to this supervisor with an offer capability')
|
|
1379
1382
|
}
|
|
1383
|
+
if (!isFunctionalWorker(worker)) throw new Error('worker must be a collaboration session')
|
|
1380
1384
|
if (!auth.isAuthorized(self.sessionId, worker)) {
|
|
1381
1385
|
throw new Error('未授权:请在“协同授权”页授权双方。')
|
|
1382
1386
|
}
|
|
@@ -2088,7 +2092,9 @@ export function apply(ctx, config = {}) {
|
|
|
2088
2092
|
return {
|
|
2089
2093
|
kind: 'success',
|
|
2090
2094
|
text: JSON.stringify({
|
|
2091
|
-
relationships: relationships.listForSupervisor(supervisor)
|
|
2095
|
+
relationships: relationships.listForSupervisor(supervisor)
|
|
2096
|
+
.filter(relationship => isFunctionalWorker(relationship.worker))
|
|
2097
|
+
.map(view),
|
|
2092
2098
|
workers: workerCandidates(supervisor),
|
|
2093
2099
|
}),
|
|
2094
2100
|
}
|
|
@@ -2097,7 +2103,7 @@ export function apply(ctx, config = {}) {
|
|
|
2097
2103
|
const worker = parts[1]
|
|
2098
2104
|
if (!isSessionId(worker) || worker === supervisor) return { kind: 'error', text: usage }
|
|
2099
2105
|
const entry = registry.get(worker)
|
|
2100
|
-
if (entry === undefined || entry.preset
|
|
2106
|
+
if (entry === undefined || entry.preset !== PRESET) return { kind: 'error', text: 'worker must be a collaboration session' }
|
|
2101
2107
|
if (action === 'unlink') {
|
|
2102
2108
|
relationships.remove(supervisor, worker)
|
|
2103
2109
|
auth.revoke(supervisor, worker)
|
|
@@ -2163,7 +2169,9 @@ export function apply(ctx, config = {}) {
|
|
|
2163
2169
|
return {
|
|
2164
2170
|
kind: 'success',
|
|
2165
2171
|
text: JSON.stringify({
|
|
2166
|
-
relationships: relationships.listForSupervisor(supervisor)
|
|
2172
|
+
relationships: relationships.listForSupervisor(supervisor)
|
|
2173
|
+
.filter(relationship => isFunctionalWorker(relationship.worker))
|
|
2174
|
+
.map(relationship => ({
|
|
2167
2175
|
...relationship,
|
|
2168
2176
|
capability: effectiveCapability(relationship),
|
|
2169
2177
|
})),
|
|
@@ -2186,7 +2194,9 @@ export function apply(ctx, config = {}) {
|
|
|
2186
2194
|
if (op === 'board') {
|
|
2187
2195
|
if (!supervisor) throw new Error('not a supervisor session')
|
|
2188
2196
|
return {
|
|
2189
|
-
relationships: relationships.listForSupervisor(sessionId)
|
|
2197
|
+
relationships: relationships.listForSupervisor(sessionId)
|
|
2198
|
+
.filter(relationship => isFunctionalWorker(relationship.worker))
|
|
2199
|
+
.map(relationship => ({
|
|
2190
2200
|
...relationship,
|
|
2191
2201
|
capability: effectiveCapability(relationship),
|
|
2192
2202
|
})),
|
|
@@ -2222,7 +2232,7 @@ export function apply(ctx, config = {}) {
|
|
|
2222
2232
|
const worker = typeof args?.worker === 'string' ? args.worker : ''
|
|
2223
2233
|
if (!isSessionId(worker) || worker === sessionId) throw new Error('invalid worker id')
|
|
2224
2234
|
const entry = registry.get(worker)
|
|
2225
|
-
if (entry === undefined || entry.preset
|
|
2235
|
+
if (entry === undefined || entry.preset !== PRESET) throw new Error('worker must be a collaboration session')
|
|
2226
2236
|
const view = relationship => relationship === undefined
|
|
2227
2237
|
? undefined
|
|
2228
2238
|
: { ...relationship, capability: effectiveCapability(relationship) }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmodelin/dsh-collab-sessions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Left-sidebar entry that creates collaboration sessions with a private/communication workspace layout and session-to-session messaging.",
|
|
6
6
|
"exports": {
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"dsh": "^0.2.2-rc.5"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@xmodelin/dsh-collab-auth-api": "0.0.
|
|
61
|
+
"@xmodelin/dsh-collab-auth-api": "0.0.2"
|
|
62
62
|
}
|
|
63
63
|
}
|