@syntrologie/adapt-chatbot 2.8.0-canary.585 → 2.8.0-canary.587
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/hostAgentController.d.ts.map +1 -1
- package/dist/runtime.js +79 -1
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostAgentController.d.ts","sourceRoot":"","sources":["../src/hostAgentController.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EACnC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,MAAM,IAAI,CAAC;IACd;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC1D;AAeD,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"hostAgentController.d.ts","sourceRoot":"","sources":["../src/hostAgentController.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EACnC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GACjC,MAAM,IAAI,CAAC;IACd;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC1D;AAeD,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAwJD,UAAU,oBAAoB;IAC5B,cAAc,CAAC,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7C;AAsJD,oFAAoF;AACpF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,OAAO,GAAE,0BAA+B;4BAuZT,OAAO,KAAG,IAAI;gCAgGJ,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;;;EAoHjE;AA0BD,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CA4D5E;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAC1B,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,EACtD,OAAO,EAAE,OAAO,GACf,IAAI,CAEN"}
|
package/dist/runtime.js
CHANGED
|
@@ -3504,6 +3504,29 @@ function cardStorage() {
|
|
|
3504
3504
|
return void 0;
|
|
3505
3505
|
}
|
|
3506
3506
|
}
|
|
3507
|
+
var STAR_TOOL = "star_card_tile";
|
|
3508
|
+
function decodeStars(value) {
|
|
3509
|
+
if (!record(value)) return void 0;
|
|
3510
|
+
const out = {};
|
|
3511
|
+
for (const [instanceId, star] of Object.entries(value)) {
|
|
3512
|
+
if (nonempty(instanceId) && record(star) && typeof star.starred === "boolean" && typeof star.updatedAt === "string")
|
|
3513
|
+
out[instanceId] = {
|
|
3514
|
+
starred: star.starred,
|
|
3515
|
+
updatedAt: star.updatedAt,
|
|
3516
|
+
...typeof star.changedAt === "string" ? { changedAt: star.changedAt } : {}
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3519
|
+
return out;
|
|
3520
|
+
}
|
|
3521
|
+
function mergeStars(held, incoming) {
|
|
3522
|
+
const out = { ...held ?? {} };
|
|
3523
|
+
for (const [instanceId, next] of Object.entries(incoming)) {
|
|
3524
|
+
const current = out[instanceId];
|
|
3525
|
+
const keepCurrent = current?.changedAt !== void 0 && (next.changedAt === void 0 || current.changedAt > next.changedAt);
|
|
3526
|
+
if (!keepCurrent) out[instanceId] = next;
|
|
3527
|
+
}
|
|
3528
|
+
return out;
|
|
3529
|
+
}
|
|
3507
3530
|
var interactionOwners = /* @__PURE__ */ new WeakMap();
|
|
3508
3531
|
function hostUiSubscription(value) {
|
|
3509
3532
|
return record(value) && typeof value.subscribeHostUi === "function";
|
|
@@ -3563,7 +3586,13 @@ function decodeAgentTurn(result) {
|
|
|
3563
3586
|
mounted_elements: snapshot.mounted_elements
|
|
3564
3587
|
};
|
|
3565
3588
|
const issuedAt = typeof payload.issuedAt === "number" && Number.isFinite(payload.issuedAt) ? payload.issuedAt : void 0;
|
|
3566
|
-
|
|
3589
|
+
const stars = decodeStars(payload.stars);
|
|
3590
|
+
return {
|
|
3591
|
+
session,
|
|
3592
|
+
frame,
|
|
3593
|
+
...issuedAt !== void 0 ? { issuedAt } : {},
|
|
3594
|
+
...stars ? { stars } : {}
|
|
3595
|
+
};
|
|
3567
3596
|
}
|
|
3568
3597
|
function activateHostAgentController(runtime2, bridge, hostUi, options = {}) {
|
|
3569
3598
|
let controller = createElementSessionController(runtime2);
|
|
@@ -3913,7 +3942,55 @@ function activateHostAgentController(runtime2, bridge, hostUi, options = {}) {
|
|
|
3913
3942
|
acceptHostUi2({ kind: "session", session: turn.session });
|
|
3914
3943
|
acceptHostUi2({ kind: "frame", frame: turn.frame });
|
|
3915
3944
|
startHeartbeat(turn.session.session_ref);
|
|
3945
|
+
boundSessionRef = turn.session.session_ref;
|
|
3946
|
+
if (turn.stars) {
|
|
3947
|
+
knownStars = mergeStars(knownStars, turn.stars);
|
|
3948
|
+
publishStars();
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
let boundSessionRef;
|
|
3952
|
+
let knownStars;
|
|
3953
|
+
function publishStars() {
|
|
3954
|
+
if (disposed || !knownStars) return;
|
|
3955
|
+
runtime2.events.publish("host.stars", { stars: { ...knownStars } });
|
|
3956
|
+
}
|
|
3957
|
+
async function requestStar(props) {
|
|
3958
|
+
const instanceId = props?.instanceId;
|
|
3959
|
+
const starred = props?.starred;
|
|
3960
|
+
if (!nonempty(instanceId) || typeof starred !== "boolean") return;
|
|
3961
|
+
const failed = () => {
|
|
3962
|
+
if (!disposed) runtime2.events.publish("host.star_failed", { instanceId });
|
|
3963
|
+
};
|
|
3964
|
+
if (!boundSessionRef || typeof bridge.callServerTool !== "function") return failed();
|
|
3965
|
+
let result;
|
|
3966
|
+
try {
|
|
3967
|
+
result = await bridge.callServerTool({
|
|
3968
|
+
name: STAR_TOOL,
|
|
3969
|
+
arguments: { sessionRef: boundSessionRef, instanceId, starred }
|
|
3970
|
+
});
|
|
3971
|
+
} catch {
|
|
3972
|
+
return failed();
|
|
3973
|
+
}
|
|
3974
|
+
const stored = record(result) && !result.isError ? result.structuredContent : void 0;
|
|
3975
|
+
if (!record(stored) || stored.instanceId !== instanceId || typeof stored.starred !== "boolean" || typeof stored.updatedAt !== "string")
|
|
3976
|
+
return failed();
|
|
3977
|
+
knownStars = mergeStars(knownStars, {
|
|
3978
|
+
[instanceId]: {
|
|
3979
|
+
starred: stored.starred,
|
|
3980
|
+
updatedAt: stored.updatedAt,
|
|
3981
|
+
...typeof stored.changedAt === "string" ? { changedAt: stored.changedAt } : {}
|
|
3982
|
+
}
|
|
3983
|
+
});
|
|
3984
|
+
publishStars();
|
|
3916
3985
|
}
|
|
3986
|
+
const stopStarRequests = runtime2.events.subscribe?.(
|
|
3987
|
+
{ names: ["canvas:star-request", "canvas:stars-request"] },
|
|
3988
|
+
(event) => {
|
|
3989
|
+
if (disposed) return;
|
|
3990
|
+
if (event.name === "canvas:stars-request") publishStars();
|
|
3991
|
+
else void requestStar(event.props);
|
|
3992
|
+
}
|
|
3993
|
+
);
|
|
3917
3994
|
const deliver = (result) => {
|
|
3918
3995
|
standDown();
|
|
3919
3996
|
void consumeToolResult(result);
|
|
@@ -3936,6 +4013,7 @@ function activateHostAgentController(runtime2, bridge, hostUi, options = {}) {
|
|
|
3936
4013
|
if (missingTimer !== void 0) clearTimeout(missingTimer);
|
|
3937
4014
|
missingTimer = void 0;
|
|
3938
4015
|
stopActivity?.();
|
|
4016
|
+
stopStarRequests?.();
|
|
3939
4017
|
stopHeartbeat();
|
|
3940
4018
|
stopObserver?.();
|
|
3941
4019
|
stopObserver = void 0;
|