@saturn-universe/projections 0.1.2-dev.6 → 0.1.2-dev.7
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/project.d.ts +1 -0
- package/dist/project.js +18 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { projectBatch, projectBatchWithChanges, createCoreProjections } from './project.js';
|
|
1
|
+
export { projectBatch, projectBatchWithChanges, createCoreProjections, sessionHasActiveRun, } from './project.js';
|
|
2
2
|
export type { ProjectionChanges } from './project.js';
|
|
3
3
|
export { coreProjectionName, coreProjectionVersion, initialProjection } from './state.js';
|
|
4
4
|
export type { ExecutionFact, ModelFact, ProjectionCollection, ProjectionIndexes, ProjectionState, } from './state.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { projectBatch, projectBatchWithChanges, createCoreProjections } from './project.js';
|
|
1
|
+
export { projectBatch, projectBatchWithChanges, createCoreProjections, sessionHasActiveRun, } from './project.js';
|
|
2
2
|
export { coreProjectionName, coreProjectionVersion, initialProjection } from './state.js';
|
|
3
3
|
export { initialSurface, reduceSurface } from './surface.js';
|
package/dist/project.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export declare function createCoreProjections(hash: Hash): {
|
|
|
18
18
|
initial: typeof initialProjection;
|
|
19
19
|
reduce: (state: ProjectionState, events: readonly RuntimeEvent[]) => ProjectionState;
|
|
20
20
|
};
|
|
21
|
+
export declare function sessionHasActiveRun(s: ProjectionState, sessionId: string): boolean;
|
package/dist/project.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { acceptsModelResponse, canonicalJson, earlierDeadline, isLimited, isTerminalRunEventType, isTerminalRunStatus, ownerAllowsRoute, resolveSubagentWallTimeMs, settledModelTokens, streamKey, RuntimeError, transitionRun, } from '@saturn-universe/core';
|
|
1
|
+
import { acceptsModelResponse, canonicalJson, contextExtensionRefPattern, earlierDeadline, isLimited, isTerminalRunEventType, isTerminalRunStatus, ownerAllowsRoute, resolveSubagentWallTimeMs, settledModelTokens, streamKey, RuntimeError, transitionRun, } from '@saturn-universe/core';
|
|
2
2
|
import { initialSurface, reduceSurface } from './surface.js';
|
|
3
3
|
import { coreProjectionName, coreProjectionVersion, emptyIndexes, initialProjection, projectionCollections, } from './state.js';
|
|
4
4
|
import { attachTeamMember, finishTeam, isDegradedWorkerTurn, planTeam, projectTeamMessage, projectTeamStopRequest, projectTeamTurn, } from './team.js';
|
|
@@ -297,6 +297,7 @@ function applyEvent(s, e, hash) {
|
|
|
297
297
|
case 'agent.created':
|
|
298
298
|
case 'session.created':
|
|
299
299
|
case 'session.agent.bound':
|
|
300
|
+
case 'session.mode.selected':
|
|
300
301
|
case 'session.archived':
|
|
301
302
|
case 'agent_session.created':
|
|
302
303
|
case 'agent_session.archived':
|
|
@@ -409,6 +410,9 @@ function reduceWorkspaceEvent(s, e, r) {
|
|
|
409
410
|
}
|
|
410
411
|
return r;
|
|
411
412
|
}
|
|
413
|
+
export function sessionHasActiveRun(s, sessionId) {
|
|
414
|
+
return someRuns(s, s.indexes.runIdsBySession[sessionId], (run) => !isTerminalRunStatus(run.status));
|
|
415
|
+
}
|
|
412
416
|
function reduceSessionEvent(s, e, r) {
|
|
413
417
|
switch (e.type) {
|
|
414
418
|
case 'agent.created':
|
|
@@ -427,6 +431,16 @@ function reduceSessionEvent(s, e, r) {
|
|
|
427
431
|
add(s.bindings, `${b.sessionId}:${b.agentSessionId}`, b);
|
|
428
432
|
break;
|
|
429
433
|
}
|
|
434
|
+
case 'session.mode.selected': {
|
|
435
|
+
const { sessionId } = e.scope;
|
|
436
|
+
const session = s.sessions[sessionId];
|
|
437
|
+
if (session.status !== 'open' || !contextExtensionRefPattern.test(e.payload.modeRef))
|
|
438
|
+
invalid('invalid session mode selection');
|
|
439
|
+
if (sessionHasActiveRun(s, sessionId))
|
|
440
|
+
invalid('session has active work');
|
|
441
|
+
s.sessions[sessionId] = { ...session, modeRef: e.payload.modeRef };
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
430
444
|
case 'session.archived': {
|
|
431
445
|
const id = e.scope.sessionId;
|
|
432
446
|
if (s.sessions[id].status !== 'open')
|
|
@@ -508,6 +522,9 @@ function reduceRunEvent(s, e, r) {
|
|
|
508
522
|
invalid('stream has unresolved calls');
|
|
509
523
|
if (m.role === 'main' && s.indexes.mainMembershipByRun[m.runId] !== undefined)
|
|
510
524
|
invalid('duplicate run main');
|
|
525
|
+
const selectedModeRef = s.sessions[e.scope.sessionId]?.modeRef;
|
|
526
|
+
if (m.role === 'main' && selectedModeRef && m.config.modeRef !== selectedModeRef)
|
|
527
|
+
invalid('Run Mode does not match the session selection');
|
|
511
528
|
if (m.config.checkpoint) {
|
|
512
529
|
const { sourceRunId, originalInputId } = m.config.checkpoint;
|
|
513
530
|
const source = s.memberships[`${sourceRunId}:${m.agentSessionId}`];
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/projections",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.7",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@saturn-universe/core": "0.1.2-dev.
|
|
10
|
+
"@saturn-universe/core": "0.1.2-dev.7"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|