@playcraft/common 0.0.53 → 0.0.56
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/agent/competitor-report.d.ts +165 -0
- package/dist/agent/competitor-report.d.ts.map +1 -0
- package/dist/agent/competitor-report.js +261 -0
- package/dist/agent/competitor-report.js.map +1 -0
- package/dist/agent/context-usage.d.ts +8 -1
- package/dist/agent/context-usage.d.ts.map +1 -1
- package/dist/agent/context-usage.js +6 -1
- package/dist/agent/context-usage.js.map +1 -1
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +5 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/model-context-window.d.ts.map +1 -1
- package/dist/agent/model-context-window.js +40 -4
- package/dist/agent/model-context-window.js.map +1 -1
- package/dist/agent/reference-images.d.ts +66 -0
- package/dist/agent/reference-images.d.ts.map +1 -0
- package/dist/agent/reference-images.js +181 -0
- package/dist/agent/reference-images.js.map +1 -0
- package/dist/agent/runtime-failure.d.ts +31 -0
- package/dist/agent/runtime-failure.d.ts.map +1 -0
- package/dist/agent/runtime-failure.js +83 -0
- package/dist/agent/runtime-failure.js.map +1 -0
- package/dist/agent/session-title.d.ts +8 -0
- package/dist/agent/session-title.d.ts.map +1 -0
- package/dist/agent/session-title.js +16 -0
- package/dist/agent/session-title.js.map +1 -0
- package/dist/agent/turn.d.ts +8 -0
- package/dist/agent/turn.d.ts.map +1 -0
- package/dist/agent/turn.js +7 -0
- package/dist/agent/turn.js.map +1 -0
- package/dist/agent-jobs/identity.d.ts +8 -0
- package/dist/agent-jobs/identity.d.ts.map +1 -0
- package/dist/agent-jobs/identity.js +32 -0
- package/dist/agent-jobs/identity.js.map +1 -0
- package/dist/agent-jobs/index.d.ts +34 -0
- package/dist/agent-jobs/index.d.ts.map +1 -0
- package/dist/agent-jobs/index.js +39 -0
- package/dist/agent-jobs/index.js.map +1 -0
- package/dist/agent-jobs/legacy-http-gone.d.ts +13 -0
- package/dist/agent-jobs/legacy-http-gone.d.ts.map +1 -0
- package/dist/agent-jobs/legacy-http-gone.js +15 -0
- package/dist/agent-jobs/legacy-http-gone.js.map +1 -0
- package/dist/agent-jobs/legacy-run-task.d.ts +12 -0
- package/dist/agent-jobs/legacy-run-task.d.ts.map +1 -0
- package/dist/agent-jobs/legacy-run-task.js +14 -0
- package/dist/agent-jobs/legacy-run-task.js.map +1 -0
- package/dist/agent-jobs/portal-sandbox-team-mount.d.ts +8 -0
- package/dist/agent-jobs/portal-sandbox-team-mount.d.ts.map +1 -0
- package/dist/agent-jobs/portal-sandbox-team-mount.js +10 -0
- package/dist/agent-jobs/portal-sandbox-team-mount.js.map +1 -0
- package/dist/agent-jobs/runtime-metrics.d.ts +12 -0
- package/dist/agent-jobs/runtime-metrics.d.ts.map +1 -0
- package/dist/agent-jobs/runtime-metrics.js +19 -0
- package/dist/agent-jobs/runtime-metrics.js.map +1 -0
- package/dist/agent-jobs/runtime-timing.d.ts +21 -0
- package/dist/agent-jobs/runtime-timing.d.ts.map +1 -0
- package/dist/agent-jobs/runtime-timing.js +20 -0
- package/dist/agent-jobs/runtime-timing.js.map +1 -0
- package/dist/agent-jobs/runtime-v2.d.ts +8 -0
- package/dist/agent-jobs/runtime-v2.d.ts.map +1 -0
- package/dist/agent-jobs/runtime-v2.js +10 -0
- package/dist/agent-jobs/runtime-v2.js.map +1 -0
- package/dist/agent-messages/db-message-converter.d.ts +61 -0
- package/dist/agent-messages/db-message-converter.d.ts.map +1 -0
- package/dist/agent-messages/db-message-converter.js +478 -0
- package/dist/agent-messages/db-message-converter.js.map +1 -0
- package/dist/agent-messages/index.d.ts +4 -0
- package/dist/agent-messages/index.d.ts.map +1 -0
- package/dist/agent-messages/index.js +4 -0
- package/dist/agent-messages/index.js.map +1 -0
- package/dist/agent-messages/message-merge.d.ts +31 -0
- package/dist/agent-messages/message-merge.d.ts.map +1 -0
- package/dist/agent-messages/message-merge.js +221 -0
- package/dist/agent-messages/message-merge.js.map +1 -0
- package/dist/agent-messages/runtime-user-messages.d.ts +51 -0
- package/dist/agent-messages/runtime-user-messages.d.ts.map +1 -0
- package/dist/agent-messages/runtime-user-messages.js +296 -0
- package/dist/agent-messages/runtime-user-messages.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/prefab/index.d.ts +1 -0
- package/dist/prefab/index.d.ts.map +1 -1
- package/dist/prefab/index.js +1 -0
- package/dist/prefab/index.js.map +1 -1
- package/dist/prefab/schema-condition.d.ts +27 -0
- package/dist/prefab/schema-condition.d.ts.map +1 -0
- package/dist/prefab/schema-condition.js +107 -0
- package/dist/prefab/schema-condition.js.map +1 -0
- package/dist/prefab/schema-walker.d.ts +46 -4
- package/dist/prefab/schema-walker.d.ts.map +1 -1
- package/dist/prefab/schema-walker.js +155 -11
- package/dist/prefab/schema-walker.js.map +1 -1
- package/dist/prefab/types.d.ts +21 -2
- package/dist/prefab/types.d.ts.map +1 -1
- package/dist/recommend/atom-graph/basic-atom-graph.d.ts.map +1 -1
- package/dist/recommend/atom-graph/basic-atom-graph.js +80 -63
- package/dist/recommend/atom-graph/basic-atom-graph.js.map +1 -1
- package/dist/recommend/atom-graph/basic-atom-skill-graph.d.ts.map +1 -1
- package/dist/recommend/atom-graph/basic-atom-skill-graph.js +8 -0
- package/dist/recommend/atom-graph/basic-atom-skill-graph.js.map +1 -1
- package/dist/storage/cos.d.ts +4 -4
- package/dist/storage/cos.d.ts.map +1 -1
- package/dist/storage/cos.js +19 -1
- package/dist/storage/cos.js.map +1 -1
- package/dist/storage/interface.d.ts +5 -1
- package/dist/storage/interface.d.ts.map +1 -1
- package/package.json +28 -2
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
export function isSubAgentMessage(message) {
|
|
2
|
+
const agentMsg = message;
|
|
3
|
+
return (typeof agentMsg._agentId === 'string' &&
|
|
4
|
+
agentMsg._agentId.length > 0);
|
|
5
|
+
}
|
|
6
|
+
/** Score message completeness for merge decisions (higher = richer). */
|
|
7
|
+
export function scoreMessageRichness(message) {
|
|
8
|
+
const parts = message.parts ?? [];
|
|
9
|
+
let score = parts.length;
|
|
10
|
+
for (const part of parts) {
|
|
11
|
+
const p = part;
|
|
12
|
+
if (typeof p.type === 'string' && p.type.startsWith('tool-')) {
|
|
13
|
+
score += 2;
|
|
14
|
+
if (p.state === 'output-available')
|
|
15
|
+
score += 1;
|
|
16
|
+
}
|
|
17
|
+
if (part.type === 'reasoning')
|
|
18
|
+
score += 1;
|
|
19
|
+
}
|
|
20
|
+
return score;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Merge two copies of the same sub-agent bubble by toolCallId.
|
|
24
|
+
* Whole-message richness scoring can drop a later pending ask_user when the
|
|
25
|
+
* stream copy only has an earlier answered ask_user (fewer parts but higher
|
|
26
|
+
* per-part score from output-available).
|
|
27
|
+
*/
|
|
28
|
+
export function mergeSubAgentPartsByToolCallId(preferred, other) {
|
|
29
|
+
const preferredParts = preferred.parts ?? [];
|
|
30
|
+
const otherParts = other.parts ?? [];
|
|
31
|
+
if (otherParts.length === 0)
|
|
32
|
+
return preferred;
|
|
33
|
+
const byId = new Map();
|
|
34
|
+
const order = [];
|
|
35
|
+
const answerQuality = (part) => {
|
|
36
|
+
if (part.state !== 'output-available')
|
|
37
|
+
return 0;
|
|
38
|
+
const out = part.output;
|
|
39
|
+
if (out == null)
|
|
40
|
+
return 0;
|
|
41
|
+
if (typeof out === 'string') {
|
|
42
|
+
return out && out !== '[object Object]' ? 2 : 0;
|
|
43
|
+
}
|
|
44
|
+
if (typeof out === 'object' && !Array.isArray(out)) {
|
|
45
|
+
const answer = out.answer;
|
|
46
|
+
if (typeof answer === 'string' && answer && answer !== '[object Object]')
|
|
47
|
+
return 3;
|
|
48
|
+
if (answer != null)
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
return 0;
|
|
52
|
+
};
|
|
53
|
+
const upsert = (part, fromPreferred) => {
|
|
54
|
+
const p = part;
|
|
55
|
+
if (typeof p.type !== 'string' || !p.type.startsWith('tool-') || !p.toolCallId) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const id = p.toolCallId;
|
|
59
|
+
const existing = byId.get(id);
|
|
60
|
+
if (!existing) {
|
|
61
|
+
byId.set(id, p);
|
|
62
|
+
order.push(id);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// Prefer output-available; among resolved copies prefer a real answer over
|
|
66
|
+
// legacy "[object Object]" garbage from String(envelope).
|
|
67
|
+
if (p.state === 'output-available' && existing.state !== 'output-available') {
|
|
68
|
+
byId.set(id, p);
|
|
69
|
+
}
|
|
70
|
+
else if (p.state === 'output-available' &&
|
|
71
|
+
existing.state === 'output-available' &&
|
|
72
|
+
answerQuality(p) > answerQuality(existing)) {
|
|
73
|
+
byId.set(id, p);
|
|
74
|
+
}
|
|
75
|
+
else if (fromPreferred && p.state === 'output-available') {
|
|
76
|
+
byId.set(id, p);
|
|
77
|
+
}
|
|
78
|
+
else if (fromPreferred && existing.state !== 'output-available') {
|
|
79
|
+
byId.set(id, p);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// Union: start with preferred order, then append missing from other.
|
|
83
|
+
for (const p of preferredParts)
|
|
84
|
+
upsert(p, true);
|
|
85
|
+
for (const p of otherParts)
|
|
86
|
+
upsert(p, false);
|
|
87
|
+
// Preserve non-tool parts from preferred in their relative positions by
|
|
88
|
+
// rebuilding: walk preferred parts, replace tools from map, then append
|
|
89
|
+
// any toolCallIds only present in other.
|
|
90
|
+
const preferredToolIds = new Set(preferredParts
|
|
91
|
+
.map((part) => part.toolCallId)
|
|
92
|
+
.filter((id) => typeof id === 'string'));
|
|
93
|
+
const mergedParts = [];
|
|
94
|
+
for (const part of preferredParts) {
|
|
95
|
+
const p = part;
|
|
96
|
+
if (typeof p.type === 'string' && p.type.startsWith('tool-') && p.toolCallId) {
|
|
97
|
+
mergedParts.push(byId.get(p.toolCallId));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
mergedParts.push(part);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
for (const id of order) {
|
|
104
|
+
if (preferredToolIds.has(id))
|
|
105
|
+
continue;
|
|
106
|
+
mergedParts.push(byId.get(id));
|
|
107
|
+
}
|
|
108
|
+
// Prefer metadata from the richer / preferred message.
|
|
109
|
+
return { ...preferred, parts: mergedParts };
|
|
110
|
+
}
|
|
111
|
+
function pickRicherMessage(a, b) {
|
|
112
|
+
if (!a)
|
|
113
|
+
return b;
|
|
114
|
+
if (!b)
|
|
115
|
+
return a;
|
|
116
|
+
if (isSubAgentMessage(a) && isSubAgentMessage(b)) {
|
|
117
|
+
// Prefer the richer copy as the base, then union tool parts so a later
|
|
118
|
+
// pending ask_user in DB is not dropped when the stream only has Q1.
|
|
119
|
+
const scoreA = scoreMessageRichness(a);
|
|
120
|
+
const scoreB = scoreMessageRichness(b);
|
|
121
|
+
// On equal score prefer `b` (DB backbone) — stream may carry stale HITL answers.
|
|
122
|
+
const preferred = scoreA > scoreB ? a : b;
|
|
123
|
+
const other = preferred === a ? b : a;
|
|
124
|
+
return mergeSubAgentPartsByToolCallId(preferred, other);
|
|
125
|
+
}
|
|
126
|
+
return scoreMessageRichness(a) >= scoreMessageRichness(b) ? a : b;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Strip an interleave segment suffix (`__tail`, `__segN`) to recover the base
|
|
130
|
+
* manager message id. `interleaveSpawnMessages` splits a manager message with a
|
|
131
|
+
* spawn_executor part into `X` (pre) + `X__tail` + sub-agent bubble; the live
|
|
132
|
+
* useChat stream keeps the same content as ONE flat message with id `X`.
|
|
133
|
+
*/
|
|
134
|
+
function segmentBaseId(id) {
|
|
135
|
+
return id.replace(/__tail$/, '').replace(/__seg\d+$/, '');
|
|
136
|
+
}
|
|
137
|
+
function userMessageText(message) {
|
|
138
|
+
return (message.parts ?? [])
|
|
139
|
+
.map((p) => (p.type === 'text' ? p.text : ''))
|
|
140
|
+
.join('')
|
|
141
|
+
.trim();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Merge live useChat messages with DB-reloaded messages after a stream ends.
|
|
145
|
+
*
|
|
146
|
+
* The DB form is the source of truth for ordering AND structure: it is already
|
|
147
|
+
* interleaved (manager pre + tail segments, then sub-agent bubbles). The live
|
|
148
|
+
* stream form is flat (spawn inline, sub-agents appended via SSE). Naively
|
|
149
|
+
* concatenating the two produces duplicates (flat manager vs DB `__tail`), wrong
|
|
150
|
+
* order, and — for user messages, whose ids never match between useChat and the
|
|
151
|
+
* backend — the same prompt twice. This merge:
|
|
152
|
+
* - uses DB messages as the ordered backbone;
|
|
153
|
+
* - never merges a flat stream manager into a DB message the backend split into
|
|
154
|
+
* segments (that would re-inline the tail → duplicate);
|
|
155
|
+
* - prefers the richer copy for sub-agent bubbles so an optimistic HITL answer
|
|
156
|
+
* (output-available in the stream) is not reverted to the DB's pending copy;
|
|
157
|
+
* - only appends stream messages with no DB counterpart, deduping user prompts
|
|
158
|
+
* across mismatched ids by text.
|
|
159
|
+
* It is idempotent: re-merging its own output against the same DB is a no-op.
|
|
160
|
+
*/
|
|
161
|
+
export function mergeSessionMessages(streamMessages, dbMessages) {
|
|
162
|
+
if (dbMessages.length === 0)
|
|
163
|
+
return streamMessages;
|
|
164
|
+
if (streamMessages.length === 0)
|
|
165
|
+
return dbMessages;
|
|
166
|
+
const streamById = new Map(streamMessages.map((m) => [m.id, m]));
|
|
167
|
+
const dbIds = new Set();
|
|
168
|
+
const dbSegmentBaseIds = new Set();
|
|
169
|
+
const dbUserTexts = new Set();
|
|
170
|
+
for (const m of dbMessages) {
|
|
171
|
+
dbIds.add(m.id);
|
|
172
|
+
const base = segmentBaseId(m.id);
|
|
173
|
+
if (base !== m.id)
|
|
174
|
+
dbSegmentBaseIds.add(base);
|
|
175
|
+
if (m.role === 'user')
|
|
176
|
+
dbUserTexts.add(userMessageText(m));
|
|
177
|
+
}
|
|
178
|
+
const result = [];
|
|
179
|
+
const seenIds = new Set();
|
|
180
|
+
const seenSubIds = new Set();
|
|
181
|
+
// Backbone: DB messages in their (already interleaved) order.
|
|
182
|
+
for (const dbMsg of dbMessages) {
|
|
183
|
+
if (isSubAgentMessage(dbMsg)) {
|
|
184
|
+
result.push(pickRicherMessage(streamById.get(dbMsg.id), dbMsg) ?? dbMsg);
|
|
185
|
+
seenSubIds.add(dbMsg.id);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
// Enrich from the flat stream copy only when the backend did NOT split this
|
|
189
|
+
// manager message into interleaved segments — otherwise the flat copy carries
|
|
190
|
+
// the tail content inline and would duplicate the DB `__tail` segment.
|
|
191
|
+
const isSplitBase = dbSegmentBaseIds.has(dbMsg.id);
|
|
192
|
+
const enriched = !isSplitBase && streamById.has(dbMsg.id)
|
|
193
|
+
? (pickRicherMessage(streamById.get(dbMsg.id), dbMsg) ?? dbMsg)
|
|
194
|
+
: dbMsg;
|
|
195
|
+
result.push(enriched);
|
|
196
|
+
seenIds.add(dbMsg.id);
|
|
197
|
+
}
|
|
198
|
+
// Append stream-only messages (not yet persisted / no DB counterpart).
|
|
199
|
+
for (const streamMsg of streamMessages) {
|
|
200
|
+
if (isSubAgentMessage(streamMsg)) {
|
|
201
|
+
if (seenSubIds.has(streamMsg.id) || dbIds.has(streamMsg.id))
|
|
202
|
+
continue;
|
|
203
|
+
result.push(streamMsg);
|
|
204
|
+
seenSubIds.add(streamMsg.id);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (seenIds.has(streamMsg.id) || dbIds.has(streamMsg.id))
|
|
208
|
+
continue;
|
|
209
|
+
// Flat manager whose interleaved segments already live in DB → skip.
|
|
210
|
+
if (dbSegmentBaseIds.has(streamMsg.id))
|
|
211
|
+
continue;
|
|
212
|
+
// User prompt already persisted under a different id (useChat vs backend).
|
|
213
|
+
if (streamMsg.role === 'user' && dbUserTexts.has(userMessageText(streamMsg))) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
result.push(streamMsg);
|
|
217
|
+
seenIds.add(streamMsg.id);
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=message-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-merge.js","sourceRoot":"","sources":["../../src/agent-messages/message-merge.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,iBAAiB,CAAC,OAAkB;IAClD,MAAM,QAAQ,GAAG,OAAyB,CAAC;IAC3C,OAAO,CACL,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ;QACrC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,oBAAoB,CAAC,OAAkB;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,IAAgB,CAAC;QAC3B,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7D,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,CAAC,CAAC,KAAK,KAAK,kBAAkB;gBAAE,KAAK,IAAI,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;YAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,SAAoB,EACpB,KAAgB;IAEhB,MAAM,cAAc,GAAG,SAAS,CAAC,KAA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G,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type DbMessageRowLike = {
|
|
2
|
+
id?: string;
|
|
3
|
+
clientMessageId?: string | null;
|
|
4
|
+
role: string;
|
|
5
|
+
content: unknown;
|
|
6
|
+
messageFormat?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type RuntimeUserMessage = {
|
|
9
|
+
role: 'user';
|
|
10
|
+
content: string;
|
|
11
|
+
/** agent_messages.id — hydrate uses this to re-attach file parts. */
|
|
12
|
+
sourceMessageId?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function messageRowMatchesCutoff(row: Pick<DbMessageRowLike, 'id' | 'clientMessageId'>, cutoffMessageId: string): boolean;
|
|
15
|
+
export type RuntimeToolResultPart = {
|
|
16
|
+
type: 'tool-result';
|
|
17
|
+
toolCallId: string;
|
|
18
|
+
toolName?: string;
|
|
19
|
+
output: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type RuntimeAssistantPart = {
|
|
22
|
+
type: 'text';
|
|
23
|
+
text: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'tool-call';
|
|
26
|
+
toolCallId: string;
|
|
27
|
+
toolName: string;
|
|
28
|
+
input: unknown;
|
|
29
|
+
};
|
|
30
|
+
export type RuntimeConversationMessage = RuntimeUserMessage | {
|
|
31
|
+
role: 'assistant';
|
|
32
|
+
content: string | RuntimeAssistantPart[];
|
|
33
|
+
} | {
|
|
34
|
+
role: 'tool';
|
|
35
|
+
content: RuntimeToolResultPart[];
|
|
36
|
+
};
|
|
37
|
+
export declare function extractRuntimeUserMessagesFromDbRows(rows: DbMessageRowLike[]): RuntimeUserMessage[];
|
|
38
|
+
/**
|
|
39
|
+
* Build Manager conversation history including assistant/tool turns.
|
|
40
|
+
* When `cutoffMessageId` is set, include messages up to and including that id
|
|
41
|
+
* (so a queued later Turn is not visible to an earlier Run).
|
|
42
|
+
*
|
|
43
|
+
* A completed Manager turn is dual-written: one `ui_v1` assistant row holding the whole turn
|
|
44
|
+
* (text + tool calls + outputs) plus one row per tool result. The assistant row is therefore the
|
|
45
|
+
* authoritative source for pairing — tool rows it already covers are skipped, because the batch
|
|
46
|
+
* insert gives every row of a turn the same `created_at` and their relative order is arbitrary.
|
|
47
|
+
*/
|
|
48
|
+
export declare function extractRuntimeConversationFromDbRows(rows: DbMessageRowLike[], options?: {
|
|
49
|
+
cutoffMessageId?: string;
|
|
50
|
+
}): RuntimeConversationMessage[];
|
|
51
|
+
//# sourceMappingURL=runtime-user-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-user-messages.d.ts","sourceRoot":"","sources":["../../src/agent-messages/runtime-user-messages.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,iBAAiB,CAAC,EACrD,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,EAAE,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,qBAAqB,EAAE,CAAA;CAAE,CAAC;AA4OvD,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,gBAAgB,EAAE,GACvB,kBAAkB,EAAE,CAetB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,gBAAgB,EAAE,EACxB,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC,0BAA0B,EAAE,CAoE9B"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
export function messageRowMatchesCutoff(row, cutoffMessageId) {
|
|
2
|
+
return row.id === cutoffMessageId || row.clientMessageId === cutoffMessageId;
|
|
3
|
+
}
|
|
4
|
+
function extractUiText(content) {
|
|
5
|
+
if (typeof content === 'string')
|
|
6
|
+
return content.trim();
|
|
7
|
+
if (!content || typeof content !== 'object')
|
|
8
|
+
return '';
|
|
9
|
+
const ui = content;
|
|
10
|
+
return (ui.parts ?? [])
|
|
11
|
+
.map((part) => (part.type === 'text' && part.text ? part.text.trim() : ''))
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join('\n')
|
|
14
|
+
.trim();
|
|
15
|
+
}
|
|
16
|
+
function extractUiUserContent(content) {
|
|
17
|
+
const text = extractUiText(content);
|
|
18
|
+
if (text)
|
|
19
|
+
return text;
|
|
20
|
+
if (!content || typeof content !== 'object')
|
|
21
|
+
return '';
|
|
22
|
+
const ui = content;
|
|
23
|
+
const hasFile = (ui.parts ?? []).some((part) => part.type === 'file');
|
|
24
|
+
return hasFile ? ' ' : '';
|
|
25
|
+
}
|
|
26
|
+
/** Mirrors backend `normalizeToolResultOutput`: AI SDK tool results must be an envelope. */
|
|
27
|
+
function toToolResultOutput(raw) {
|
|
28
|
+
if (raw !== null && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
29
|
+
const type = raw.type;
|
|
30
|
+
if (type === 'text' ||
|
|
31
|
+
type === 'json' ||
|
|
32
|
+
type === 'error-text' ||
|
|
33
|
+
type === 'error-json' ||
|
|
34
|
+
type === 'execution-denied' ||
|
|
35
|
+
type === 'content') {
|
|
36
|
+
return raw;
|
|
37
|
+
}
|
|
38
|
+
return { type: 'json', value: raw };
|
|
39
|
+
}
|
|
40
|
+
if (typeof raw === 'string')
|
|
41
|
+
return { type: 'text', value: raw };
|
|
42
|
+
return { type: 'text', value: JSON.stringify(raw) };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read the tool-aware structure of an assistant row.
|
|
46
|
+
*
|
|
47
|
+
* `ui_v1` rows keep interleaved `text` / `tool-<name>` parts (each tool part carries
|
|
48
|
+
* `toolCallId` + `input` + `output`); legacy rows keep raw content blocks. Both shapes are
|
|
49
|
+
* flattened to the same block list so tool calls survive the round-trip through the database.
|
|
50
|
+
* Returns null for plain-text rows, which stay on the text-only path.
|
|
51
|
+
*/
|
|
52
|
+
function readAssistantBlocks(content) {
|
|
53
|
+
const raw = Array.isArray(content)
|
|
54
|
+
? content
|
|
55
|
+
: content && typeof content === 'object' && Array.isArray(content.parts)
|
|
56
|
+
? (content.parts)
|
|
57
|
+
: null;
|
|
58
|
+
if (!raw)
|
|
59
|
+
return null;
|
|
60
|
+
const blocks = [];
|
|
61
|
+
for (const entry of raw) {
|
|
62
|
+
if (!entry || typeof entry !== 'object')
|
|
63
|
+
continue;
|
|
64
|
+
const part = entry;
|
|
65
|
+
if (part.type === 'text') {
|
|
66
|
+
const text = typeof part.text === 'string' ? part.text.trim() : '';
|
|
67
|
+
if (text)
|
|
68
|
+
blocks.push({ kind: 'text', text });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const toolName = part.type === 'tool-call' || part.type === 'tool_call'
|
|
72
|
+
? part.toolName
|
|
73
|
+
: typeof part.type === 'string' && part.type.startsWith('tool-')
|
|
74
|
+
? part.type.slice('tool-'.length)
|
|
75
|
+
: undefined;
|
|
76
|
+
if (!toolName || typeof part.toolCallId !== 'string')
|
|
77
|
+
continue;
|
|
78
|
+
blocks.push({
|
|
79
|
+
kind: 'tool',
|
|
80
|
+
toolCallId: part.toolCallId,
|
|
81
|
+
toolName,
|
|
82
|
+
input: part.input ?? part.args ?? null,
|
|
83
|
+
output: part.output,
|
|
84
|
+
resolved: part.state === 'output-available',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return blocks.length > 0 ? blocks : null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Re-split an assistant row into the assistant / tool message alternation the providers require:
|
|
91
|
+
* every `tool` message must directly follow the assistant message carrying its `tool_calls`.
|
|
92
|
+
* A text block that comes after tool calls starts the next step.
|
|
93
|
+
*/
|
|
94
|
+
function expandAssistantBlocks(blocks, envelopedOutputs) {
|
|
95
|
+
const messages = [];
|
|
96
|
+
let texts = [];
|
|
97
|
+
let calls = [];
|
|
98
|
+
const flush = () => {
|
|
99
|
+
if (calls.length === 0) {
|
|
100
|
+
const text = texts.join('\n').trim();
|
|
101
|
+
if (text)
|
|
102
|
+
messages.push({ role: 'assistant', content: text });
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const parts = [];
|
|
106
|
+
const text = texts.join('\n').trim();
|
|
107
|
+
if (text)
|
|
108
|
+
parts.push({ type: 'text', text });
|
|
109
|
+
for (const call of calls) {
|
|
110
|
+
parts.push({
|
|
111
|
+
type: 'tool-call',
|
|
112
|
+
toolCallId: call.toolCallId,
|
|
113
|
+
toolName: call.toolName,
|
|
114
|
+
input: call.input,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
messages.push({ role: 'assistant', content: parts });
|
|
118
|
+
messages.push({
|
|
119
|
+
role: 'tool',
|
|
120
|
+
content: calls.map((call) => ({
|
|
121
|
+
type: 'tool-result',
|
|
122
|
+
toolCallId: call.toolCallId,
|
|
123
|
+
toolName: call.toolName,
|
|
124
|
+
output: call.output,
|
|
125
|
+
})),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
texts = [];
|
|
129
|
+
calls = [];
|
|
130
|
+
};
|
|
131
|
+
for (const block of blocks) {
|
|
132
|
+
if (block.kind === 'text') {
|
|
133
|
+
if (calls.length > 0)
|
|
134
|
+
flush();
|
|
135
|
+
texts.push(block.text);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// A tool call the model never got an answer for would dangle in the next request.
|
|
139
|
+
const enveloped = envelopedOutputs.get(block.toolCallId);
|
|
140
|
+
if (enveloped === undefined && !block.resolved)
|
|
141
|
+
continue;
|
|
142
|
+
calls.push({
|
|
143
|
+
toolCallId: block.toolCallId,
|
|
144
|
+
toolName: block.toolName,
|
|
145
|
+
input: block.input,
|
|
146
|
+
output: enveloped ?? toToolResultOutput(block.output ?? null),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
flush();
|
|
150
|
+
return messages;
|
|
151
|
+
}
|
|
152
|
+
function collectToolResultParts(content) {
|
|
153
|
+
if (!Array.isArray(content))
|
|
154
|
+
return [];
|
|
155
|
+
const parts = [];
|
|
156
|
+
for (const entry of content) {
|
|
157
|
+
if (!entry || typeof entry !== 'object')
|
|
158
|
+
continue;
|
|
159
|
+
const part = entry;
|
|
160
|
+
if ((part.type === 'tool-result' || part.type === 'tool_result') &&
|
|
161
|
+
typeof part.toolCallId === 'string') {
|
|
162
|
+
parts.push({
|
|
163
|
+
type: 'tool-result',
|
|
164
|
+
toolCallId: part.toolCallId,
|
|
165
|
+
toolName: typeof part.toolName === 'string' ? part.toolName : undefined,
|
|
166
|
+
output: part.output ?? part.result ?? null,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return parts;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Last line of defence: drop any `tool` message that is not answering the immediately preceding
|
|
174
|
+
* assistant `tool_calls`. Providers reject the whole request on a single orphan.
|
|
175
|
+
*/
|
|
176
|
+
function dropOrphanToolMessages(messages) {
|
|
177
|
+
return messages.filter((message, index) => {
|
|
178
|
+
if (message.role !== 'tool')
|
|
179
|
+
return true;
|
|
180
|
+
const previous = messages[index - 1];
|
|
181
|
+
if (!previous || previous.role !== 'assistant' || !Array.isArray(previous.content))
|
|
182
|
+
return false;
|
|
183
|
+
const answered = new Set(previous.content
|
|
184
|
+
.filter((part) => part.type === 'tool-call')
|
|
185
|
+
.map((part) => part.toolCallId));
|
|
186
|
+
return message.content.every((part) => answered.has(part.toolCallId));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function toRuntimeUserMessage(row, text) {
|
|
190
|
+
return row.id
|
|
191
|
+
? { role: 'user', content: text, sourceMessageId: row.id }
|
|
192
|
+
: { role: 'user', content: text };
|
|
193
|
+
}
|
|
194
|
+
function extractUserRowText(row) {
|
|
195
|
+
if (typeof row.content === 'string')
|
|
196
|
+
return row.content.trim();
|
|
197
|
+
return extractUiUserContent(row.content);
|
|
198
|
+
}
|
|
199
|
+
export function extractRuntimeUserMessagesFromDbRows(rows) {
|
|
200
|
+
const messages = [];
|
|
201
|
+
for (const message of rows) {
|
|
202
|
+
if (message.role !== 'user')
|
|
203
|
+
continue;
|
|
204
|
+
if (typeof message.content === 'string') {
|
|
205
|
+
const text = message.content.trim();
|
|
206
|
+
if (text)
|
|
207
|
+
messages.push(toRuntimeUserMessage(message, text));
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (message.messageFormat === 'ui_v1' && message.content && typeof message.content === 'object') {
|
|
211
|
+
const text = extractUiUserContent(message.content);
|
|
212
|
+
if (text)
|
|
213
|
+
messages.push(toRuntimeUserMessage(message, text));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return messages;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Build Manager conversation history including assistant/tool turns.
|
|
220
|
+
* When `cutoffMessageId` is set, include messages up to and including that id
|
|
221
|
+
* (so a queued later Turn is not visible to an earlier Run).
|
|
222
|
+
*
|
|
223
|
+
* A completed Manager turn is dual-written: one `ui_v1` assistant row holding the whole turn
|
|
224
|
+
* (text + tool calls + outputs) plus one row per tool result. The assistant row is therefore the
|
|
225
|
+
* authoritative source for pairing — tool rows it already covers are skipped, because the batch
|
|
226
|
+
* insert gives every row of a turn the same `created_at` and their relative order is arbitrary.
|
|
227
|
+
*/
|
|
228
|
+
export function extractRuntimeConversationFromDbRows(rows, options) {
|
|
229
|
+
const cutoff = options?.cutoffMessageId;
|
|
230
|
+
const visible = [];
|
|
231
|
+
for (const row of rows) {
|
|
232
|
+
visible.push(row);
|
|
233
|
+
if (cutoff && messageRowMatchesCutoff(row, cutoff))
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
const envelopedOutputs = new Map();
|
|
237
|
+
const coveredToolCallIds = new Set();
|
|
238
|
+
for (const row of visible) {
|
|
239
|
+
if (row.role === 'tool' || row.role === 'toolResult') {
|
|
240
|
+
for (const part of collectToolResultParts(row.content)) {
|
|
241
|
+
envelopedOutputs.set(part.toolCallId, part.output);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else if (row.role === 'assistant') {
|
|
245
|
+
for (const block of readAssistantBlocks(row.content) ?? []) {
|
|
246
|
+
if (block.kind === 'tool')
|
|
247
|
+
coveredToolCallIds.add(block.toolCallId);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const messages = [];
|
|
252
|
+
for (const message of visible) {
|
|
253
|
+
if (cutoff && messageRowMatchesCutoff(message, cutoff)) {
|
|
254
|
+
// Include the cutoff user/assistant message, then stop.
|
|
255
|
+
if (message.role === 'user') {
|
|
256
|
+
const text = extractUserRowText(message);
|
|
257
|
+
if (text)
|
|
258
|
+
messages.push(toRuntimeUserMessage(message, text));
|
|
259
|
+
}
|
|
260
|
+
else if (message.role === 'assistant') {
|
|
261
|
+
const text = typeof message.content === 'string'
|
|
262
|
+
? message.content.trim()
|
|
263
|
+
: extractUiText(message.content);
|
|
264
|
+
if (text)
|
|
265
|
+
messages.push({ role: 'assistant', content: text });
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
if (message.role === 'user') {
|
|
270
|
+
const text = extractUserRowText(message);
|
|
271
|
+
if (text)
|
|
272
|
+
messages.push(toRuntimeUserMessage(message, text));
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (message.role === 'assistant') {
|
|
276
|
+
const blocks = readAssistantBlocks(message.content);
|
|
277
|
+
if (blocks) {
|
|
278
|
+
messages.push(...expandAssistantBlocks(blocks, envelopedOutputs));
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const text = typeof message.content === 'string'
|
|
282
|
+
? message.content.trim()
|
|
283
|
+
: extractUiText(message.content);
|
|
284
|
+
if (text)
|
|
285
|
+
messages.push({ role: 'assistant', content: text });
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (message.role === 'tool' || message.role === 'toolResult') {
|
|
289
|
+
const parts = collectToolResultParts(message.content).filter((part) => !coveredToolCallIds.has(part.toolCallId));
|
|
290
|
+
if (parts.length > 0)
|
|
291
|
+
messages.push({ role: 'tool', content: parts });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return dropOrphanToolMessages(messages);
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=runtime-user-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-user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G,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;gBAClE,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GACR,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;gBACjC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;gBACxB,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrC,IAAI,IAAI;gBAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,SAAS;QACX,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC7D,MAAM,KAAK,GAAG,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAC1D,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CACnD,CAAC;YACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,sBAAsB,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,4 +17,6 @@ export * from './queue/email-queue.js';
|
|
|
17
17
|
export * from './queue/remix-cover-queue.js';
|
|
18
18
|
export * from './preview/phone-preview-dimensions.js';
|
|
19
19
|
export * from './image-studio/index.js';
|
|
20
|
+
export * from './agent-jobs/index.js';
|
|
21
|
+
export * from './agent/index.js';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,6 @@ export * from './queue/email-queue.js';
|
|
|
17
17
|
export * from './queue/remix-cover-queue.js';
|
|
18
18
|
export * from './preview/phone-preview-dimensions.js';
|
|
19
19
|
export * from './image-studio/index.js';
|
|
20
|
+
export * from './agent-jobs/index.js';
|
|
21
|
+
export * from './agent/index.js';
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/prefab/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './constants.js';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './theme-schema-parser.js';
|
|
4
4
|
export * from './schema-walker.js';
|
|
5
|
+
export * from './schema-condition.js';
|
|
5
6
|
export * from './extension-parser.js';
|
|
6
7
|
export * from './scene-resolver.js';
|
|
7
8
|
export * from './validator.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prefab/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prefab/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
package/dist/prefab/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './constants.js';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './theme-schema-parser.js';
|
|
4
4
|
export * from './schema-walker.js';
|
|
5
|
+
export * from './schema-condition.js';
|
|
5
6
|
export * from './extension-parser.js';
|
|
6
7
|
export * from './scene-resolver.js';
|
|
7
8
|
export * from './validator.js';
|