@eum-agent/automation-schedule 1.0.0 → 1.1.0
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.js +712 -75
- package/package.json +4 -4
- package/ui/ui.js +212 -150
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "Scheduled Automation",
|
|
5
5
|
"zh-CN": "定时任务"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.1.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "Time-based and recurring agent execution",
|
|
10
10
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@eum-agent/container": "1.0.0",
|
|
26
26
|
"@eum-agent/kernel": "1.0.0",
|
|
27
|
-
"@eum-agent/plugin": "1.
|
|
27
|
+
"@eum-agent/plugin": "1.1.0",
|
|
28
28
|
"@eum-agent/protocol": "1.0.0",
|
|
29
29
|
"@types/react": "^19.2.18",
|
|
30
30
|
"@types/react-dom": "^19.2.5",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dependencies": {},
|
|
41
41
|
"kind": "extension",
|
|
42
42
|
"foundationDependencies": {
|
|
43
|
-
"@eum-agent/infra-local": "1.0.
|
|
44
|
-
"@eum-agent/storage-sqlite": "1.
|
|
43
|
+
"@eum-agent/infra-local": "1.0.1",
|
|
44
|
+
"@eum-agent/storage-sqlite": "1.1.0"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
package/ui/ui.js
CHANGED
|
@@ -668,6 +668,199 @@ function stateOf(trigger, next, words) {
|
|
|
668
668
|
return null;
|
|
669
669
|
}
|
|
670
670
|
//#endregion
|
|
671
|
+
//#region src/ui/wire.ts
|
|
672
|
+
/** The minted source this plugin's definitions carry. */
|
|
673
|
+
var SOURCE = "plugin:@eum-agent/automation-schedule:schedule";
|
|
674
|
+
/** A definition's config read back; `null` for one that is not a rule. */
|
|
675
|
+
function configOf(raw) {
|
|
676
|
+
if (typeof raw !== "object" || raw === null) return null;
|
|
677
|
+
const { rule, catchUp } = raw;
|
|
678
|
+
if (typeof rule !== "object" || rule === null) return null;
|
|
679
|
+
const kind = rule.kind;
|
|
680
|
+
if (kind !== "once" && kind !== "interval" && kind !== "cron") return null;
|
|
681
|
+
return {
|
|
682
|
+
rule,
|
|
683
|
+
catchUp: catchUp !== false
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/ui/store.ts
|
|
688
|
+
var EMPTY = {
|
|
689
|
+
tasks: null,
|
|
690
|
+
tasksFailed: false,
|
|
691
|
+
pendingActions: {},
|
|
692
|
+
agents: [],
|
|
693
|
+
sessions: [],
|
|
694
|
+
next: {},
|
|
695
|
+
pictures: {}
|
|
696
|
+
};
|
|
697
|
+
/** A picture revision belongs to its agent and cannot address another agent's bytes. */
|
|
698
|
+
function pictureKey(agentId, rev) {
|
|
699
|
+
return JSON.stringify([agentId, rev]);
|
|
700
|
+
}
|
|
701
|
+
/** One list's reader: at most one read in flight and one queued behind it. */
|
|
702
|
+
function reader(read) {
|
|
703
|
+
let running = false;
|
|
704
|
+
let again = false;
|
|
705
|
+
const run = () => {
|
|
706
|
+
if (running) {
|
|
707
|
+
again = true;
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
running = true;
|
|
711
|
+
read().finally(() => {
|
|
712
|
+
running = false;
|
|
713
|
+
if (again) {
|
|
714
|
+
again = false;
|
|
715
|
+
run();
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
return run;
|
|
720
|
+
}
|
|
721
|
+
function createScheduleStore(ctx) {
|
|
722
|
+
let state = EMPTY;
|
|
723
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
724
|
+
const inflight = /* @__PURE__ */ new Set();
|
|
725
|
+
const actionIntents = /* @__PURE__ */ new Map();
|
|
726
|
+
const pictureQueue = [];
|
|
727
|
+
let picturesRunning = false;
|
|
728
|
+
let connectionEpoch = 0;
|
|
729
|
+
let connectionStatus = ctx.gateway.connection.status;
|
|
730
|
+
const stopConnection = ctx.gateway.watchConnection((connection) => {
|
|
731
|
+
if (connection.status === connectionStatus) return;
|
|
732
|
+
connectionStatus = connection.status;
|
|
733
|
+
connectionEpoch += 1;
|
|
734
|
+
});
|
|
735
|
+
ctx.signal.addEventListener("abort", stopConnection, { once: true });
|
|
736
|
+
let holders = 0;
|
|
737
|
+
let stop = null;
|
|
738
|
+
const set = (patch) => {
|
|
739
|
+
state = {
|
|
740
|
+
...state,
|
|
741
|
+
...patch
|
|
742
|
+
};
|
|
743
|
+
for (const listener of [...listeners]) listener();
|
|
744
|
+
};
|
|
745
|
+
const readPictures = async () => {
|
|
746
|
+
if (picturesRunning) return;
|
|
747
|
+
picturesRunning = true;
|
|
748
|
+
try {
|
|
749
|
+
while (pictureQueue.length) {
|
|
750
|
+
const group = pictureQueue.splice(0, 4);
|
|
751
|
+
const epoch = connectionEpoch;
|
|
752
|
+
const pictures = {};
|
|
753
|
+
try {
|
|
754
|
+
const answer = await ctx.call("config.agent.avatars", { agentIds: group.map((one) => one.agentId) });
|
|
755
|
+
for (const [index, one] of group.entries()) {
|
|
756
|
+
const result = answer.results[index];
|
|
757
|
+
const image = result?.ok ? result.value : null;
|
|
758
|
+
pictures[pictureKey(one.agentId, one.rev)] = image !== null && image.rev === one.rev ? `data:${image.mediaType};base64,${image.data}` : null;
|
|
759
|
+
}
|
|
760
|
+
} catch {
|
|
761
|
+
for (const one of group) pictures[pictureKey(one.agentId, one.rev)] = null;
|
|
762
|
+
} finally {
|
|
763
|
+
for (const one of group) inflight.delete(pictureKey(one.agentId, one.rev));
|
|
764
|
+
}
|
|
765
|
+
if (!ctx.signal.aborted && connectionEpoch === epoch) set({ pictures: {
|
|
766
|
+
...state.pictures,
|
|
767
|
+
...pictures
|
|
768
|
+
} });
|
|
769
|
+
}
|
|
770
|
+
} finally {
|
|
771
|
+
picturesRunning = false;
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
const loadTasks = reader(() => ctx.call("trigger.list", {}).then(({ triggers }) => set({
|
|
775
|
+
tasks: triggers.filter((one) => one.source === SOURCE),
|
|
776
|
+
tasksFailed: false
|
|
777
|
+
})).catch((error) => set({ tasksFailed: state.tasks === null && failureText$1(ctx, error) !== null })).then(() => void 0));
|
|
778
|
+
const loadAgents = reader(() => ctx.call("config.agent.list", {}).then((agents) => set({ agents })).catch(() => void 0));
|
|
779
|
+
const loadSessions = reader(() => ctx.call("session.list", {}).then((sessions) => set({ sessions })).catch(() => void 0));
|
|
780
|
+
const loadNext = reader(() => ctx.invoke("nextRuns", {}).then(({ next }) => set({ next })).catch(() => void 0));
|
|
781
|
+
const loadAll = () => {
|
|
782
|
+
loadTasks();
|
|
783
|
+
loadAgents();
|
|
784
|
+
loadSessions();
|
|
785
|
+
loadNext();
|
|
786
|
+
};
|
|
787
|
+
function start() {
|
|
788
|
+
let connection = ctx.host.get().connection;
|
|
789
|
+
const offs = [
|
|
790
|
+
ctx.onCore("trigger.changed", loadTasks),
|
|
791
|
+
ctx.onCore("config.agentChanged", loadAgents),
|
|
792
|
+
ctx.onCore("config.agentRemoved", loadAgents),
|
|
793
|
+
ctx.onCore("session.created", loadSessions),
|
|
794
|
+
ctx.onCore("session.updated", loadSessions),
|
|
795
|
+
ctx.on("nextRunsChanged", (event) => set({ next: event.payload.next })),
|
|
796
|
+
ctx.host.subscribe(() => {
|
|
797
|
+
const now = ctx.host.get().connection;
|
|
798
|
+
if (now === "online" && connection !== "online") loadAll();
|
|
799
|
+
connection = now;
|
|
800
|
+
})
|
|
801
|
+
];
|
|
802
|
+
loadAll();
|
|
803
|
+
return () => {
|
|
804
|
+
for (const off of offs) off();
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
return {
|
|
808
|
+
get: () => state,
|
|
809
|
+
subscribe(listener) {
|
|
810
|
+
listeners.add(listener);
|
|
811
|
+
return () => {
|
|
812
|
+
listeners.delete(listener);
|
|
813
|
+
};
|
|
814
|
+
},
|
|
815
|
+
retain() {
|
|
816
|
+
holders += 1;
|
|
817
|
+
if (holders === 1) stop = start();
|
|
818
|
+
let released = false;
|
|
819
|
+
return () => {
|
|
820
|
+
if (released) return;
|
|
821
|
+
released = true;
|
|
822
|
+
holders -= 1;
|
|
823
|
+
if (holders === 0) {
|
|
824
|
+
stop?.();
|
|
825
|
+
stop = null;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
},
|
|
829
|
+
reloadTasks: loadTasks,
|
|
830
|
+
async runTaskAction(id, intent, action) {
|
|
831
|
+
if (state.pendingActions[id]) return;
|
|
832
|
+
const key = JSON.stringify([id, intent]);
|
|
833
|
+
const operationId = actionIntents.get(key) ?? ctx.uuid();
|
|
834
|
+
actionIntents.set(key, operationId);
|
|
835
|
+
set({ pendingActions: {
|
|
836
|
+
...state.pendingActions,
|
|
837
|
+
[id]: true
|
|
838
|
+
} });
|
|
839
|
+
try {
|
|
840
|
+
const receipt = await action(operationId);
|
|
841
|
+
if (receipt.operationId !== operationId) throw new Error("task operation identity mismatch");
|
|
842
|
+
if (receipt.operationState === "admitted") throw new Error("task operation is awaiting settlement; retry the original intent");
|
|
843
|
+
if (receipt.operationState === "cleanup-pending") throw new Error("task change committed but cleanup is pending; retry the original intent");
|
|
844
|
+
actionIntents.delete(key);
|
|
845
|
+
} finally {
|
|
846
|
+
const pendingActions = { ...state.pendingActions };
|
|
847
|
+
delete pendingActions[id];
|
|
848
|
+
set({ pendingActions });
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
requestPicture(agentId, rev) {
|
|
852
|
+
const key = pictureKey(agentId, rev);
|
|
853
|
+
if (key in state.pictures || inflight.has(key)) return;
|
|
854
|
+
inflight.add(key);
|
|
855
|
+
pictureQueue.push({
|
|
856
|
+
agentId,
|
|
857
|
+
rev
|
|
858
|
+
});
|
|
859
|
+
queueMicrotask(() => void readPictures());
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
//#endregion
|
|
671
864
|
//#region src/ui/env.tsx
|
|
672
865
|
var EnvContext = createContext(null);
|
|
673
866
|
var EnvProvider = EnvContext.Provider;
|
|
@@ -728,7 +921,7 @@ function AgentFace({ agentId, size = "md", className }) {
|
|
|
728
921
|
const { ctx, store } = useEnv();
|
|
729
922
|
const agent = useSchedule((state) => state.agents.find((one) => one.agentId === agentId));
|
|
730
923
|
const rev = agent?.avatar ?? null;
|
|
731
|
-
const src = useSchedule((state) => rev === null ? null : state.pictures[rev] ?? null);
|
|
924
|
+
const src = useSchedule((state) => rev === null ? null : state.pictures[pictureKey(agentId, rev)] ?? null);
|
|
732
925
|
useEffect(() => {
|
|
733
926
|
if (rev !== null) store.requestPicture(agentId, rev);
|
|
734
927
|
}, [
|
|
@@ -757,6 +950,7 @@ function AgentFace({ agentId, size = "md", className }) {
|
|
|
757
950
|
var TOOL_NAMES = [
|
|
758
951
|
"schedule_create",
|
|
759
952
|
"schedule_list",
|
|
953
|
+
"schedule_read",
|
|
760
954
|
"schedule_update",
|
|
761
955
|
"schedule_delete"
|
|
762
956
|
];
|
|
@@ -768,6 +962,7 @@ var CATALOGUES = {
|
|
|
768
962
|
group: "Schedules",
|
|
769
963
|
schedule_create: "Create scheduled task",
|
|
770
964
|
schedule_list: "List scheduled tasks",
|
|
965
|
+
schedule_read: "Read scheduled task",
|
|
771
966
|
schedule_update: "Edit scheduled task",
|
|
772
967
|
schedule_delete: "Delete scheduled task"
|
|
773
968
|
},
|
|
@@ -776,6 +971,7 @@ var CATALOGUES = {
|
|
|
776
971
|
group: "计划任务",
|
|
777
972
|
schedule_create: "新建计划任务",
|
|
778
973
|
schedule_list: "查看计划任务",
|
|
974
|
+
schedule_read: "读取计划任务",
|
|
779
975
|
schedule_update: "修改计划任务",
|
|
780
976
|
schedule_delete: "删除计划任务"
|
|
781
977
|
}
|
|
@@ -1421,22 +1617,6 @@ function Timing({ cadence, anchor, catchUp, onCadence, onCatchUp }) {
|
|
|
1421
1617
|
});
|
|
1422
1618
|
}
|
|
1423
1619
|
//#endregion
|
|
1424
|
-
//#region src/ui/wire.ts
|
|
1425
|
-
/** The minted source this plugin's definitions carry. */
|
|
1426
|
-
var SOURCE = "plugin:@eum-agent/automation-schedule:schedule";
|
|
1427
|
-
/** A definition's config read back; `null` for one that is not a rule. */
|
|
1428
|
-
function configOf(raw) {
|
|
1429
|
-
if (typeof raw !== "object" || raw === null) return null;
|
|
1430
|
-
const { rule, catchUp } = raw;
|
|
1431
|
-
if (typeof rule !== "object" || rule === null) return null;
|
|
1432
|
-
const kind = rule.kind;
|
|
1433
|
-
if (kind !== "once" && kind !== "interval" && kind !== "cron") return null;
|
|
1434
|
-
return {
|
|
1435
|
-
rule,
|
|
1436
|
-
catchUp: catchUp !== false
|
|
1437
|
-
};
|
|
1438
|
-
}
|
|
1439
|
-
//#endregion
|
|
1440
1620
|
//#region src/ui/editor.tsx
|
|
1441
1621
|
/**
|
|
1442
1622
|
* The dialog that creates or changes a scheduled task.
|
|
@@ -1763,16 +1943,20 @@ function useTaskActions(trigger) {
|
|
|
1763
1943
|
const { ctx, store } = useEnv();
|
|
1764
1944
|
const pending = useSchedule((state) => !!state.pendingActions[trigger.id]);
|
|
1765
1945
|
const fail = useFailureToast();
|
|
1766
|
-
const run = (call) => {
|
|
1767
|
-
store.runTaskAction(trigger.id, call).catch((error) => fail(error));
|
|
1946
|
+
const run = (intent, call) => {
|
|
1947
|
+
store.runTaskAction(trigger.id, intent, call).catch((error) => fail(error));
|
|
1768
1948
|
};
|
|
1769
1949
|
return {
|
|
1770
1950
|
pending,
|
|
1771
|
-
toggle: () => run(() => ctx.call("trigger.setEnabled", {
|
|
1772
|
-
|
|
1951
|
+
toggle: () => run(`enabled:${!trigger.enabled}`, (operationId) => ctx.call("trigger.setEnabled", {
|
|
1952
|
+
operationId,
|
|
1953
|
+
ids: [trigger.id],
|
|
1773
1954
|
enabled: !trigger.enabled
|
|
1774
1955
|
})),
|
|
1775
|
-
remove: () => run(() => ctx.call("trigger.remove", {
|
|
1956
|
+
remove: () => run("remove", (operationId) => ctx.call("trigger.remove", {
|
|
1957
|
+
operationId,
|
|
1958
|
+
ids: [trigger.id]
|
|
1959
|
+
}))
|
|
1776
1960
|
};
|
|
1777
1961
|
}
|
|
1778
1962
|
function IconAction({ label, icon, onClick, onBlur, className, pending = false }) {
|
|
@@ -1925,7 +2109,12 @@ function Runs({ trigger }) {
|
|
|
1925
2109
|
let live = true;
|
|
1926
2110
|
setRuns(null);
|
|
1927
2111
|
setFailed(false);
|
|
1928
|
-
const read = (first) => ctx.call("trigger.runs", {
|
|
2112
|
+
const read = (first) => ctx.call("trigger.runs", { ids: [trigger.id] }).then((answer) => {
|
|
2113
|
+
const item = answer.results[0];
|
|
2114
|
+
if (!item) throw new Error("missing task run result");
|
|
2115
|
+
if (!item.ok) throw new Error(item.error.message);
|
|
2116
|
+
if (live) setRuns(item.value.runs);
|
|
2117
|
+
}).catch((error) => {
|
|
1929
2118
|
if (!live || !first) return;
|
|
1930
2119
|
setFailed(true);
|
|
1931
2120
|
fail(error);
|
|
@@ -2382,133 +2571,6 @@ function settingsFor(ctx) {
|
|
|
2382
2571
|
};
|
|
2383
2572
|
}
|
|
2384
2573
|
//#endregion
|
|
2385
|
-
//#region src/ui/store.ts
|
|
2386
|
-
var EMPTY = {
|
|
2387
|
-
tasks: null,
|
|
2388
|
-
tasksFailed: false,
|
|
2389
|
-
pendingActions: {},
|
|
2390
|
-
agents: [],
|
|
2391
|
-
sessions: [],
|
|
2392
|
-
next: {},
|
|
2393
|
-
pictures: {}
|
|
2394
|
-
};
|
|
2395
|
-
/** One list's reader: at most one read in flight and one queued behind it. */
|
|
2396
|
-
function reader(read) {
|
|
2397
|
-
let running = false;
|
|
2398
|
-
let again = false;
|
|
2399
|
-
const run = () => {
|
|
2400
|
-
if (running) {
|
|
2401
|
-
again = true;
|
|
2402
|
-
return;
|
|
2403
|
-
}
|
|
2404
|
-
running = true;
|
|
2405
|
-
read().finally(() => {
|
|
2406
|
-
running = false;
|
|
2407
|
-
if (again) {
|
|
2408
|
-
again = false;
|
|
2409
|
-
run();
|
|
2410
|
-
}
|
|
2411
|
-
});
|
|
2412
|
-
};
|
|
2413
|
-
return run;
|
|
2414
|
-
}
|
|
2415
|
-
function createScheduleStore(ctx) {
|
|
2416
|
-
let state = EMPTY;
|
|
2417
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
2418
|
-
const inflight = /* @__PURE__ */ new Set();
|
|
2419
|
-
let holders = 0;
|
|
2420
|
-
let stop = null;
|
|
2421
|
-
const set = (patch) => {
|
|
2422
|
-
state = {
|
|
2423
|
-
...state,
|
|
2424
|
-
...patch
|
|
2425
|
-
};
|
|
2426
|
-
for (const listener of [...listeners]) listener();
|
|
2427
|
-
};
|
|
2428
|
-
const loadTasks = reader(() => ctx.call("trigger.list", {}).then(({ triggers }) => set({
|
|
2429
|
-
tasks: triggers.filter((one) => one.source === SOURCE),
|
|
2430
|
-
tasksFailed: false
|
|
2431
|
-
})).catch((error) => set({ tasksFailed: state.tasks === null && failureText$1(ctx, error) !== null })).then(() => void 0));
|
|
2432
|
-
const loadAgents = reader(() => ctx.call("config.agent.list", {}).then((agents) => set({ agents })).catch(() => void 0));
|
|
2433
|
-
const loadSessions = reader(() => ctx.call("session.list", {}).then((sessions) => set({ sessions })).catch(() => void 0));
|
|
2434
|
-
const loadNext = reader(() => ctx.invoke("nextRuns", {}).then(({ next }) => set({ next })).catch(() => void 0));
|
|
2435
|
-
const loadAll = () => {
|
|
2436
|
-
loadTasks();
|
|
2437
|
-
loadAgents();
|
|
2438
|
-
loadSessions();
|
|
2439
|
-
loadNext();
|
|
2440
|
-
};
|
|
2441
|
-
function start() {
|
|
2442
|
-
let connection = ctx.host.get().connection;
|
|
2443
|
-
const offs = [
|
|
2444
|
-
ctx.onCore("trigger.changed", loadTasks),
|
|
2445
|
-
ctx.onCore("config.agentChanged", loadAgents),
|
|
2446
|
-
ctx.onCore("config.agentRemoved", loadAgents),
|
|
2447
|
-
ctx.onCore("session.created", loadSessions),
|
|
2448
|
-
ctx.onCore("session.updated", loadSessions),
|
|
2449
|
-
ctx.on("nextRunsChanged", (event) => set({ next: event.payload.next })),
|
|
2450
|
-
ctx.host.subscribe(() => {
|
|
2451
|
-
const now = ctx.host.get().connection;
|
|
2452
|
-
if (now === "online" && connection !== "online") loadAll();
|
|
2453
|
-
connection = now;
|
|
2454
|
-
})
|
|
2455
|
-
];
|
|
2456
|
-
loadAll();
|
|
2457
|
-
return () => {
|
|
2458
|
-
for (const off of offs) off();
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
return {
|
|
2462
|
-
get: () => state,
|
|
2463
|
-
subscribe(listener) {
|
|
2464
|
-
listeners.add(listener);
|
|
2465
|
-
return () => {
|
|
2466
|
-
listeners.delete(listener);
|
|
2467
|
-
};
|
|
2468
|
-
},
|
|
2469
|
-
retain() {
|
|
2470
|
-
holders += 1;
|
|
2471
|
-
if (holders === 1) stop = start();
|
|
2472
|
-
let released = false;
|
|
2473
|
-
return () => {
|
|
2474
|
-
if (released) return;
|
|
2475
|
-
released = true;
|
|
2476
|
-
holders -= 1;
|
|
2477
|
-
if (holders === 0) {
|
|
2478
|
-
stop?.();
|
|
2479
|
-
stop = null;
|
|
2480
|
-
}
|
|
2481
|
-
};
|
|
2482
|
-
},
|
|
2483
|
-
reloadTasks: loadTasks,
|
|
2484
|
-
async runTaskAction(id, action) {
|
|
2485
|
-
if (state.pendingActions[id]) return;
|
|
2486
|
-
set({ pendingActions: {
|
|
2487
|
-
...state.pendingActions,
|
|
2488
|
-
[id]: true
|
|
2489
|
-
} });
|
|
2490
|
-
try {
|
|
2491
|
-
await action();
|
|
2492
|
-
} finally {
|
|
2493
|
-
const pendingActions = { ...state.pendingActions };
|
|
2494
|
-
delete pendingActions[id];
|
|
2495
|
-
set({ pendingActions });
|
|
2496
|
-
}
|
|
2497
|
-
},
|
|
2498
|
-
requestPicture(agentId, rev) {
|
|
2499
|
-
if (rev in state.pictures || inflight.has(rev)) return;
|
|
2500
|
-
inflight.add(rev);
|
|
2501
|
-
ctx.call("config.agent.avatar", { agentId }).then((answer) => set({ pictures: {
|
|
2502
|
-
...state.pictures,
|
|
2503
|
-
[rev]: answer === null ? null : `data:${answer.mediaType};base64,${answer.data}`
|
|
2504
|
-
} })).catch(() => set({ pictures: {
|
|
2505
|
-
...state.pictures,
|
|
2506
|
-
[rev]: null
|
|
2507
|
-
} })).finally(() => inflight.delete(rev));
|
|
2508
|
-
}
|
|
2509
|
-
};
|
|
2510
|
-
}
|
|
2511
|
-
//#endregion
|
|
2512
2574
|
//#region src/ui/index.tsx
|
|
2513
2575
|
/** The host compares this against its own before calling `register`. */
|
|
2514
2576
|
var runtimeVersion = 5;
|