@volter/supercode-orchestrator 0.4.9 → 0.4.10
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/apply/doors.mjs +5 -5
- package/cron.mjs +38 -1
- package/package.json +1 -1
- package/reducer.mjs +1 -1
package/apply/doors.mjs
CHANGED
|
@@ -72,7 +72,7 @@ export function differs(want, live) {
|
|
|
72
72
|
*/
|
|
73
73
|
function declaredOnly(spec, inference, rename) {
|
|
74
74
|
const want = { schedule: spec.schedule };
|
|
75
|
-
for (const field of ['prompt', 'skills', 'deliver', 'workdir', 'repeat', 'script', 'no_agent', 'monitor_script', 'monitor_url', 'toolsets', 'context_from']) {
|
|
75
|
+
for (const field of ['prompt', 'skills', 'deliver', 'attach_to_session', 'workdir', 'repeat', 'script', 'no_agent', 'monitor_script', 'monitor_url', 'toolsets', 'context_from']) {
|
|
76
76
|
if (spec[field] !== undefined) want[rename[field] ?? field] = spec[field];
|
|
77
77
|
}
|
|
78
78
|
if (spec.model !== undefined) Object.assign(want, namedModel(spec, inference));
|
|
@@ -152,7 +152,7 @@ export function hermesDoor({ home, python = null, source = null, runner = null,
|
|
|
152
152
|
id: job.id,
|
|
153
153
|
name: job.name ?? null,
|
|
154
154
|
managed: {
|
|
155
|
-
schedule: job.schedule ?? null, prompt: job.prompt ?? null, skills: job.skills ?? null, deliver: job.deliver ?? null,
|
|
155
|
+
schedule: job.schedule ?? null, prompt: job.prompt ?? null, skills: job.skills ?? null, deliver: job.deliver ?? null, attach_to_session: job.attach_to_session ?? null,
|
|
156
156
|
model: job.model ?? null, provider: job.provider ?? null, workdir: job.workdir ?? null, repeat: job.repeat?.times ?? null,
|
|
157
157
|
script: job.script ?? null, no_agent: Boolean(job.no_agent), monitor_script: job.monitor_script ?? null,
|
|
158
158
|
monitor_url: job.monitor_url ?? null, enabled_toolsets: job.enabled_toolsets ?? null, context_from: job.context_from ?? null,
|
|
@@ -234,7 +234,7 @@ export async function orchestratorDoor({ root, profile = 'default', load, socket
|
|
|
234
234
|
id: job.id,
|
|
235
235
|
name: job.residue?.name ?? null,
|
|
236
236
|
managed: {
|
|
237
|
-
schedule: job.schedule ?? null, prompt: job.prompt ?? null, skills: job.skills ?? null, deliver: deliver(job.deliver),
|
|
237
|
+
schedule: job.schedule ?? null, prompt: job.prompt ?? null, skills: job.skills ?? null, deliver: deliver(job.deliver), attach_to_session: job.attach_to_session ?? null,
|
|
238
238
|
model: job.model ?? null, workdir: job.workdir ?? null, repeat: job.repeat?.times ?? null,
|
|
239
239
|
script: job.residue?.script ?? null, no_agent: job.residue?.no_agent === true, monitor_script: job.residue?.monitor_script ?? null,
|
|
240
240
|
monitor_url: job.residue?.monitor_url ?? null, context_from: job.context_from ?? null,
|
|
@@ -254,7 +254,7 @@ export async function orchestratorDoor({ root, profile = 'default', load, socket
|
|
|
254
254
|
return row;
|
|
255
255
|
};
|
|
256
256
|
/** What jobs.update can change; a change to anything else is refused per record, never dropped. */
|
|
257
|
-
const UPDATABLE = new Set(['schedule', 'prompt', 'deliver', 'model', 'workdir', 'script', 'no_agent', 'monitor_script', 'monitor_url']);
|
|
257
|
+
const UPDATABLE = new Set(['schedule', 'prompt', 'deliver', 'attach_to_session', 'model', 'workdir', 'script', 'no_agent', 'monitor_script', 'monitor_url']);
|
|
258
258
|
return {
|
|
259
259
|
target: 'orchestrator',
|
|
260
260
|
list,
|
|
@@ -289,4 +289,4 @@ export async function orchestratorDoor({ root, profile = 'default', load, socket
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/** The job fields the applier owns: the union both doors read (a door that has no such field reads null). */
|
|
292
|
-
export const MANAGED_JOB_FIELDS = Object.freeze(['schedule', 'prompt', 'skills', 'deliver', 'model', 'provider', 'workdir', 'repeat', 'script', 'no_agent', 'monitor_script', 'monitor_url', 'enabled_toolsets', 'context_from']);
|
|
292
|
+
export const MANAGED_JOB_FIELDS = Object.freeze(['schedule', 'prompt', 'skills', 'deliver', 'attach_to_session', 'model', 'provider', 'workdir', 'repeat', 'script', 'no_agent', 'monitor_script', 'monitor_url', 'enabled_toolsets', 'context_from']);
|
package/cron.mjs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { surfaceKeyString } from './ir.mjs';
|
|
14
14
|
import { homeChannel } from './ir.mjs';
|
|
15
|
-
import { endBinding, ensureRuntime, leaseId, newObligation, permissionResponse, reply } from './reducer.mjs';
|
|
15
|
+
import { endBinding, ensureRuntime, leaseId, newObligation, permissionResponse, reply, startWorker } from './reducer.mjs';
|
|
16
16
|
|
|
17
17
|
/** Retry delays after the 1st, 2nd and 3rd send attempt (§4.3 "retry pending obligations"). */
|
|
18
18
|
export const BACKOFF_MINUTES = Object.freeze([1, 2, 4]);
|
|
@@ -799,6 +799,7 @@ function launchFire(state, profile, job, fire, prompt, now, effects) {
|
|
|
799
799
|
deliverResult(state, profile, { job, fire }, fire.error, true, now, effects);
|
|
800
800
|
return;
|
|
801
801
|
}
|
|
802
|
+
if (job.attach_to_session === true && attachFire(state, profile, job, fire, prompt, now, effects)) return;
|
|
802
803
|
const rt = ensureRuntime(state);
|
|
803
804
|
|
|
804
805
|
const key = { platform: 'cron', kind: 'dm', chat_id: job.id };
|
|
@@ -819,6 +820,42 @@ function launchFire(state, profile, job, fire, prompt, now, effects) {
|
|
|
819
820
|
effects.push({ type: 'save' });
|
|
820
821
|
}
|
|
821
822
|
|
|
823
|
+
/**
|
|
824
|
+
* `attach_to_session`: the fire is a turn in the live session of the conversation it delivers to, taken the way an
|
|
825
|
+
* inbound message there is: it steers the running turn where the worker takes input mid-turn, waits behind it
|
|
826
|
+
* otherwise, and reopens the conversation's own session when its worker is gone. The conversation's reply is the
|
|
827
|
+
* delivery, so the fire is done once it is handed over. False (a session of its own) when that conversation has
|
|
828
|
+
* no live binding.
|
|
829
|
+
*/
|
|
830
|
+
function attachFire(state, profile, job, fire, prompt, now, effects) {
|
|
831
|
+
const target = resolveTarget(job, profile);
|
|
832
|
+
if (!target?.platform) return false;
|
|
833
|
+
const found = Object.entries(profile.bindings).find(([ks, b]) => !b.ended_at && !ks.includes('#')
|
|
834
|
+
&& b.key.platform === target.platform && String(b.key.chat_id ?? '') === String(target.chat_id ?? '')
|
|
835
|
+
&& String(b.key.thread_id ?? '') === String(target.thread_id ?? ''));
|
|
836
|
+
if (!found) return false;
|
|
837
|
+
const [keyString, binding] = found;
|
|
838
|
+
const rt = ensureRuntime(state);
|
|
839
|
+
const lid = leaseId(profile.name, keyString);
|
|
840
|
+
if (!rt.leases[lid] && !rt.turns[lid] && !rt.starting[lid]) {
|
|
841
|
+
if (binding.worker.session_id) binding.residue.resume_runtime_id ??= binding.residue.runtime_id ?? binding.worker.session_id;
|
|
842
|
+
startWorker(state, profile, keyString, effects);
|
|
843
|
+
}
|
|
844
|
+
binding.last_activity_at = now;
|
|
845
|
+
const text = `[scheduled: ${job.name ?? job.id}] ${prompt}`;
|
|
846
|
+
if (rt.turns[lid] && rt.leases[lid]?.steer) effects.push({ type: 'steer_input', profile: profile.name, keyString, text });
|
|
847
|
+
else if (rt.turns[lid] || !rt.leases[lid]) (rt.queues[lid] ??= []).push({ text, at: now, job_id: job.id });
|
|
848
|
+
else {
|
|
849
|
+
rt.turns[lid] = { started_at: now, buffer: '' };
|
|
850
|
+
effects.push({ type: 'send_input', profile: profile.name, keyString, text });
|
|
851
|
+
}
|
|
852
|
+
fire.started_at = now;
|
|
853
|
+
fire.residue = { ...(fire.residue ?? {}), attached_to: keyString };
|
|
854
|
+
finishFire(profile, fire, job, 'succeeded', now, null, effects);
|
|
855
|
+
effects.push({ type: 'save' });
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
|
|
822
859
|
function retryObligations(state, profile, now, effects) {
|
|
823
860
|
const rt = ensureRuntime(state);
|
|
824
861
|
const t = Date.parse(now);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-orchestrator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
|
|
6
6
|
"exports": {
|
package/reducer.mjs
CHANGED
|
@@ -228,7 +228,7 @@ function handleInbound(state, ev, effects) {
|
|
|
228
228
|
* a burst of messages before the lease exists queues behind ONE start (the
|
|
229
229
|
* `started`/`error` worker events clear the mark).
|
|
230
230
|
*/
|
|
231
|
-
function startWorker(state, profile, keyString, effects) {
|
|
231
|
+
export function startWorker(state, profile, keyString, effects) {
|
|
232
232
|
const rt = ensureRuntime(state);
|
|
233
233
|
rt.starting[leaseId(profile.name, keyString)] = true;
|
|
234
234
|
// A binding whose runtime went away with the daemon reopens that same session where its harness can, so the
|