@myagentroam/node 0.9.100 → 0.9.101
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/connector.js
CHANGED
|
@@ -56,7 +56,7 @@ import { ContinuousRunCoordinator } from './service/continuous-run-coordinator.j
|
|
|
56
56
|
import { SessionIdentityService } from './service/session-identity-service.js';
|
|
57
57
|
import { NativeSessionProjectionService } from './service/native-session-projection-service.js';
|
|
58
58
|
import { composeConversationRuntimePage, ConversationHistoryService, convergeConversationWatchPage, hasManagedActiveRun } from './service/conversation-history-service.js';
|
|
59
|
-
import { ConversationSegmentService,
|
|
59
|
+
import { ConversationSegmentService, conversationSegments } from './service/conversation-segment-service.js';
|
|
60
60
|
import { RunnerInteractionService } from './service/runner-interaction-service.js';
|
|
61
61
|
import { SessionLifecycleService } from './service/session-lifecycle-service.js';
|
|
62
62
|
import { ExternalSessionResumeService } from './service/external-session-resume-service.js';
|
|
@@ -1793,19 +1793,10 @@ export class NodeConnector {
|
|
|
1793
1793
|
handleMessage = (raw) => this.controlMessages.handle(raw);
|
|
1794
1794
|
emitRunEvent = (runId, eventType, payload, status) => this.runEventBridge.emitRun(runId, eventType, payload, status);
|
|
1795
1795
|
emitConversationItem = (runId, item) => {
|
|
1796
|
-
this.runEventService.flushPendingText(runId);
|
|
1797
1796
|
if (this.continuousRunCoordinator.pending(runId)?.mission !== undefined &&
|
|
1798
1797
|
isMissionProgressItem(item))
|
|
1799
1798
|
this.missionExecutionProgress.add(runId);
|
|
1800
|
-
|
|
1801
|
-
const itemKind = isPlainRecord(item) && typeof item.kind === 'string' ? item.kind : undefined;
|
|
1802
|
-
const turn = this.runtime.conversationTurnForRun(runId);
|
|
1803
|
-
const segment = itemId === undefined || turn === undefined
|
|
1804
|
-
? undefined
|
|
1805
|
-
: conversationSegmentIdentityForItem(turn, itemId, itemKind);
|
|
1806
|
-
this.runEventBridge.emitRun(runId, 'conversation.item', segment === undefined || !isPlainRecord(item)
|
|
1807
|
-
? item
|
|
1808
|
-
: { ...item, segmentId: segment.id, segmentIndex: segment.index });
|
|
1799
|
+
this.runEventBridge.emitConversationItem(runId, item);
|
|
1809
1800
|
};
|
|
1810
1801
|
emitConversationTurn = (turn) => {
|
|
1811
1802
|
const segments = isPlainRecord(turn) && Array.isArray(turn.items) ? conversationSegments(turn) : [];
|
|
@@ -1829,63 +1820,9 @@ export class NodeConnector {
|
|
|
1829
1820
|
this.emitWorkbenchEvent('session', payload);
|
|
1830
1821
|
};
|
|
1831
1822
|
emitWorkbenchEvent = (category, payload) => {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
payload.event.eventType !== 'notification') {
|
|
1836
|
-
const runId = typeof payload.event.runId === 'string' ? payload.event.runId : undefined;
|
|
1837
|
-
const sequence = typeof payload.event.sequence === 'number' ? payload.event.sequence : undefined;
|
|
1838
|
-
const turn = runId === undefined ? undefined : this.runtime.conversationTurnForRun(runId);
|
|
1839
|
-
if (turn === undefined)
|
|
1840
|
-
return;
|
|
1841
|
-
const rawPayload = isPlainRecord(payload.event.payload) ? payload.event.payload : undefined;
|
|
1842
|
-
const text = payload.event.eventType === 'text.delta' && typeof rawPayload?.text === 'string'
|
|
1843
|
-
? rawPayload.text
|
|
1844
|
-
: undefined;
|
|
1845
|
-
const nativeItemId = typeof rawPayload?.itemId === 'string'
|
|
1846
|
-
? rawPayload.itemId
|
|
1847
|
-
: typeof rawPayload?.approvalId === 'string'
|
|
1848
|
-
? `approval:${rawPayload.approvalId}`
|
|
1849
|
-
: undefined;
|
|
1850
|
-
const item = text !== undefined && sequence !== undefined
|
|
1851
|
-
? turn.items.find((candidate) => candidate.kind === 'assistant_message' && candidate.revision === sequence)
|
|
1852
|
-
: nativeItemId === undefined
|
|
1853
|
-
? undefined
|
|
1854
|
-
: turn.items.find((candidate) => candidate.id === `${runId}:${nativeItemId}`);
|
|
1855
|
-
if (text !== undefined && item?.kind === 'assistant_message') {
|
|
1856
|
-
payload = {
|
|
1857
|
-
sessionId: turn.sessionId,
|
|
1858
|
-
delta: {
|
|
1859
|
-
runId: turn.runId,
|
|
1860
|
-
itemId: item.id,
|
|
1861
|
-
text,
|
|
1862
|
-
createdAt: typeof payload.event.createdAt === 'number' ? payload.event.createdAt : Date.now()
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
else if (item !== undefined) {
|
|
1867
|
-
const segment = conversationSegmentIdentityForItem(turn, item.id, item.kind);
|
|
1868
|
-
payload = {
|
|
1869
|
-
sessionId: turn.sessionId,
|
|
1870
|
-
runId: turn.runId,
|
|
1871
|
-
item: {
|
|
1872
|
-
itemId: item.id,
|
|
1873
|
-
kind: item.kind,
|
|
1874
|
-
status: item.status,
|
|
1875
|
-
payload: item.payload,
|
|
1876
|
-
startedAt: item.startedAt,
|
|
1877
|
-
completedAt: item.completedAt,
|
|
1878
|
-
segmentId: segment.id,
|
|
1879
|
-
segmentIndex: segment.index
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
}
|
|
1883
|
-
else {
|
|
1884
|
-
if (payload.event.eventType !== 'run.started' && payload.event.eventType !== 'run.running')
|
|
1885
|
-
return;
|
|
1886
|
-
payload = { turn, segments: conversationSegments(turn) };
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1823
|
+
payload = this.runEventBridge.projectWorkbenchPayload(category, payload);
|
|
1824
|
+
if (payload === undefined)
|
|
1825
|
+
return;
|
|
1889
1826
|
const event = this.workbenchEventService.next(category, payload);
|
|
1890
1827
|
if (event === undefined)
|
|
1891
1828
|
return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { conversationSegmentIdentityForItem, conversationSegments } from './conversation-segment-service.js';
|
|
1
2
|
import { isNodeAgentRun, isNodeConversationTurn, isPlainRecord } from '../runner/codex/conversation-parser.js';
|
|
2
3
|
export function workbenchPayloadSessionId(runtime, category, payload) {
|
|
3
4
|
if (!isPlainRecord(payload))
|
|
@@ -34,6 +35,75 @@ export class NodeRunEventBridge {
|
|
|
34
35
|
constructor(options) {
|
|
35
36
|
this.options = options;
|
|
36
37
|
}
|
|
38
|
+
/** The sole public projection boundary for normalized Run callbacks. */
|
|
39
|
+
projectWorkbenchPayload(category, payload) {
|
|
40
|
+
if (category === 'conversation' &&
|
|
41
|
+
isPlainRecord(payload) &&
|
|
42
|
+
isPlainRecord(payload.event) &&
|
|
43
|
+
payload.event.eventType !== 'notification') {
|
|
44
|
+
const runId = typeof payload.event.runId === 'string' ? payload.event.runId : undefined;
|
|
45
|
+
const sequence = typeof payload.event.sequence === 'number' ? payload.event.sequence : undefined;
|
|
46
|
+
const turn = runId === undefined ? undefined : this.options.runtime.conversationTurnForRun(runId);
|
|
47
|
+
if (turn === undefined)
|
|
48
|
+
return;
|
|
49
|
+
const rawPayload = isPlainRecord(payload.event.payload) ? payload.event.payload : undefined;
|
|
50
|
+
const text = payload.event.eventType === 'text.delta' && typeof rawPayload?.text === 'string'
|
|
51
|
+
? rawPayload.text
|
|
52
|
+
: undefined;
|
|
53
|
+
const nativeItemId = typeof rawPayload?.itemId === 'string'
|
|
54
|
+
? rawPayload.itemId
|
|
55
|
+
: typeof rawPayload?.approvalId === 'string'
|
|
56
|
+
? `approval:${rawPayload.approvalId}`
|
|
57
|
+
: undefined;
|
|
58
|
+
const item = text !== undefined && sequence !== undefined
|
|
59
|
+
? turn.items.find((candidate) => candidate.kind === 'assistant_message' && candidate.revision === sequence)
|
|
60
|
+
: nativeItemId === undefined
|
|
61
|
+
? undefined
|
|
62
|
+
: turn.items.find((candidate) => candidate.id === `${runId}:${nativeItemId}`);
|
|
63
|
+
if (text !== undefined && item?.kind === 'assistant_message') {
|
|
64
|
+
const segment = conversationSegmentIdentityForItem(turn, item.id, item.kind);
|
|
65
|
+
payload = {
|
|
66
|
+
sessionId: turn.sessionId,
|
|
67
|
+
delta: {
|
|
68
|
+
turnId: turn.id,
|
|
69
|
+
segmentId: segment.id,
|
|
70
|
+
segmentIndex: segment.index,
|
|
71
|
+
runId: turn.runId,
|
|
72
|
+
itemId: item.id,
|
|
73
|
+
text,
|
|
74
|
+
createdAt: typeof payload.event.createdAt === 'number' ? payload.event.createdAt : Date.now()
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (item !== undefined) {
|
|
79
|
+
const segment = conversationSegmentIdentityForItem(turn, item.id, item.kind);
|
|
80
|
+
payload = {
|
|
81
|
+
sessionId: turn.sessionId,
|
|
82
|
+
runId: turn.runId,
|
|
83
|
+
item: {
|
|
84
|
+
turnId: turn.id,
|
|
85
|
+
itemId: item.id,
|
|
86
|
+
kind: item.kind,
|
|
87
|
+
status: item.status,
|
|
88
|
+
payload: item.payload,
|
|
89
|
+
startedAt: item.startedAt,
|
|
90
|
+
completedAt: item.completedAt,
|
|
91
|
+
segmentId: segment.id,
|
|
92
|
+
segmentIndex: segment.index
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
if (payload.event.eventType !== 'run.started' && payload.event.eventType !== 'run.running')
|
|
98
|
+
return;
|
|
99
|
+
payload = { turn, segments: conversationSegments(turn) };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return payload;
|
|
103
|
+
}
|
|
104
|
+
emitConversationItem(runId, item) {
|
|
105
|
+
this.emitRun(runId, 'conversation.item', item);
|
|
106
|
+
}
|
|
37
107
|
publishApproval(input) {
|
|
38
108
|
this.options.send('approval.request', input);
|
|
39
109
|
this.emitRun(input.runId, 'approval.request', input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myagentroam/node",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.101",
|
|
4
4
|
"description": "MyAgentRoam Node runtime CLI.",
|
|
5
5
|
"license": "Apache-2.0 AND GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"npm": "11.12.1",
|
|
31
31
|
"ws": "^8.21.3",
|
|
32
32
|
"zod": "4.4.3",
|
|
33
|
-
"@myagentroam/agent": "0.9.
|
|
34
|
-
"@myagentroam/code-navigation": "0.9.
|
|
35
|
-
"@myagentroam/protocol": "0.9.
|
|
33
|
+
"@myagentroam/agent": "0.9.101",
|
|
34
|
+
"@myagentroam/code-navigation": "0.9.101",
|
|
35
|
+
"@myagentroam/protocol": "0.9.101"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/ws": "^8.18.1"
|