oasis_test_v2 2.2.51 → 2.2.52
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 +220 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1418,6 +1418,19 @@ function windowMessagesByTurns(messages, turns) {
|
|
|
1418
1418
|
}
|
|
1419
1419
|
return { messages, hasMoreBefore: false };
|
|
1420
1420
|
}
|
|
1421
|
+
function isChatHistoryMessage(m2) {
|
|
1422
|
+
if (m2.role === "system") return m2.needsAgentDelivery === true;
|
|
1423
|
+
return !(m2.role === "assistant" && m2.status === "running");
|
|
1424
|
+
}
|
|
1425
|
+
function pageChatHistory(messages, query) {
|
|
1426
|
+
const needle = query.search?.trim().toLowerCase();
|
|
1427
|
+
const matched = messages.filter((m2) => isChatHistoryMessage(m2) && (query.beforeSeq === void 0 || m2.seq < query.beforeSeq) && (!needle || m2.content.toLowerCase().includes(needle)));
|
|
1428
|
+
const limit = Math.max(0, query.limit);
|
|
1429
|
+
return {
|
|
1430
|
+
messages: limit > 0 ? matched.slice(-limit) : [],
|
|
1431
|
+
hasMoreBefore: matched.length > limit
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1421
1434
|
var CHAT_MODEL_OVERRIDE_RUNTIMES, systemMessageSourceKey, deriveSystemMessageKey, deriveSystemMessageId, CHAT_SUBMIT_KEY_PREFIX, chatSubmitMessageKey, clientSubmitIdFromMessageKey, optimisticUserItemId;
|
|
1422
1435
|
var init_chat_session = __esm({
|
|
1423
1436
|
"../contract/src/chat-session.ts"() {
|
|
@@ -167040,6 +167053,9 @@ function renderPendingBroadcasts(items) {
|
|
|
167040
167053
|
return `${i + 1}. ${body2}${b2.at ? `\uFF08${b2.at}\uFF09` : ""}`;
|
|
167041
167054
|
});
|
|
167042
167055
|
if (folded > 0) lines.push(`\uFF08\u53E6\u6709 ${folded} \u9879\u66F4\u65E9\u7684\u901A\u544A\u672A\u5C55\u5F00\uFF09`);
|
|
167056
|
+
if (folded > 0 || detailed.some((b2) => b2.text.length > BROADCAST_TEXT_LIMIT)) {
|
|
167057
|
+
lines.push("\uFF08\u672A\u5C55\u5F00\u6216\u622A\u65AD\u7684\u901A\u544A\u5168\u6587\uFF0C\u9700\u8981\u65F6\u53EF\u4EE5\u7528 `oasis chat-history --search <\u5173\u952E\u8BCD>` \u67E5\uFF09");
|
|
167058
|
+
}
|
|
167043
167059
|
return [
|
|
167044
167060
|
"\u3010\u4EE5\u4E0B\u662F\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u53D1\u8D77\u7684\u4E8B\u60C5\u7684\u6700\u65B0\u8FDB\u5C55\uFF0C\u4F60\u4E4B\u524D\u6CA1\u770B\u5230\u8FC7\uFF1B\u7528\u6237\u5DF2\u7ECF\u5728\u754C\u9762\u4E0A\u770B\u5230\u4E86\u8FD9\u51E0\u6761\u72B6\u6001\u3011",
|
|
167045
167061
|
...lines,
|
|
@@ -167064,12 +167080,18 @@ function renderPendingUserMessages(items) {
|
|
|
167064
167080
|
""
|
|
167065
167081
|
].join("\n");
|
|
167066
167082
|
}
|
|
167083
|
+
function renderHistoryHint(count2, hint) {
|
|
167084
|
+
return `\uFF08\u4EE5\u4E0A\u662F\u8FD9\u6BB5\u5BF9\u8BDD\u6700\u8FD1\u7684 ${count2} \u6761\uFF0C\u66F4\u65E9\u7684\u6CA1\u6709\u5E26\u8FDB\u6765\u3002\u5982\u679C\u9700\u8981\u7684\u8BDD\uFF0C\u53EF\u4EE5\u8FD0\u884C \`oasis chat-history ${hint.sessionId} --before ${hint.beforeSeq}\` \u83B7\u53D6\u66F4\u65E9\u7684\u5BF9\u8BDD\uFF0C\u6216\u52A0 \`--search <\u5173\u952E\u8BCD>\` \u5728\u6574\u6BB5\u5BF9\u8BDD\u91CC\u641C\u7D22\u3002\uFF09`;
|
|
167085
|
+
}
|
|
167067
167086
|
function buildRuntimeChatPrompt(input) {
|
|
167068
167087
|
let prompt2 = input.userMessage;
|
|
167069
167088
|
if (input.history?.length) {
|
|
167070
167089
|
const history = input.history.map((message) => `${HISTORY_SPEAKER[message.role]}: ${message.content}`).join("\n\n");
|
|
167090
|
+
const hint = input.historyHint ? `
|
|
167091
|
+
|
|
167092
|
+
${renderHistoryHint(input.history.length, input.historyHint)}` : "";
|
|
167071
167093
|
prompt2 = `${OPEN}
|
|
167072
|
-
${history}
|
|
167094
|
+
${history}${hint}
|
|
167073
167095
|
${CLOSE}
|
|
167074
167096
|
|
|
167075
167097
|
${prompt2}`;
|
|
@@ -167527,6 +167549,7 @@ ${body2}` : UNFINISHED_EMPTY;
|
|
|
167527
167549
|
function toHistory(messages, excludeMessageKey) {
|
|
167528
167550
|
return messages.filter((m2) => m2.role === "system" ? isDeliveredAgentNotice(m2) : !(m2.role === "assistant" && m2.status === "running")).filter((m2) => !excludeMessageKey || m2.messageKey !== excludeMessageKey).map((m2) => ({
|
|
167529
167551
|
id: m2.id,
|
|
167552
|
+
seq: m2.seq,
|
|
167530
167553
|
role: m2.role,
|
|
167531
167554
|
content: m2.role === "user" ? stripInjectedChatContext(m2.content) : m2.role === "system" ? m2.content : m2.status === "error" ? markUnfinishedAssistant(m2.content) : m2.content
|
|
167532
167555
|
}));
|
|
@@ -167548,22 +167571,29 @@ async function planChatContinuation(input) {
|
|
|
167548
167571
|
const trailing = input.excludeTrailingUserContent?.trim();
|
|
167549
167572
|
const last = turns[turns.length - 1];
|
|
167550
167573
|
if (trailing && last?.role === "user" && last.content.trim() === trailing) turns.pop();
|
|
167551
|
-
|
|
167574
|
+
const hasEarlier = rows.length >= limit * HISTORY_FETCH_SLACK || turns.length > limit;
|
|
167575
|
+
return { turns: turns.slice(-limit), hasEarlier };
|
|
167552
167576
|
};
|
|
167553
|
-
const
|
|
167577
|
+
const hintFor = (w2) => w2.hasEarlier && w2.turns.length ? { historyHint: { sessionId: session.id, beforeSeq: w2.turns[0].seq } } : {};
|
|
167578
|
+
const NO_HISTORY = { turns: [], hasEarlier: false };
|
|
167579
|
+
const historyWindow = needsHistoryInjection ? await readHistory() : NO_HISTORY;
|
|
167580
|
+
const history = historyWindow.turns;
|
|
167554
167581
|
const pendingBroadcasts = input.pendingBroadcasts?.length ? input.pendingBroadcasts : void 0;
|
|
167555
167582
|
const persistedSystemNotices = input.persistedSystemNotices?.length ? input.persistedSystemNotices : void 0;
|
|
167556
167583
|
const runtimeMessage = buildRuntimeChatPrompt({
|
|
167557
167584
|
userMessage: input.userMessage,
|
|
167558
167585
|
...history.length ? { history: history.map(({ role, content: content3 }) => ({ role, content: content3 })) } : {},
|
|
167586
|
+
...hintFor(historyWindow),
|
|
167559
167587
|
...input.draftWorkspace ? { draftWorkspace: input.draftWorkspace } : {},
|
|
167560
167588
|
...pendingBroadcasts ? { pendingBroadcasts } : {},
|
|
167561
167589
|
...persistedSystemNotices ? { persistedSystemNotices } : {}
|
|
167562
167590
|
});
|
|
167563
|
-
const
|
|
167591
|
+
const fallbackWindow = effectiveSessionId ? await readHistory() : NO_HISTORY;
|
|
167592
|
+
const fallbackHistory = fallbackWindow.turns;
|
|
167564
167593
|
const fallbackMessage = fallbackHistory.length ? buildRuntimeChatPrompt({
|
|
167565
167594
|
userMessage: input.userMessage,
|
|
167566
167595
|
history: fallbackHistory.map(({ role, content: content3 }) => ({ role, content: content3 })),
|
|
167596
|
+
...hintFor(fallbackWindow),
|
|
167567
167597
|
...input.draftWorkspace ? { draftWorkspace: input.draftWorkspace } : {},
|
|
167568
167598
|
// resume 扑空后的重派也要带上通告:那一轮才是真正送到 agent 的那一轮。
|
|
167569
167599
|
...pendingBroadcasts ? { pendingBroadcasts } : {},
|
|
@@ -240738,6 +240768,72 @@ var init_reply_anchors = __esm({
|
|
|
240738
240768
|
}
|
|
240739
240769
|
});
|
|
240740
240770
|
|
|
240771
|
+
// ../server/src/domains/chat-sessions/agent-history.ts
|
|
240772
|
+
async function resolveChatHistoryViewer(auth, getSession) {
|
|
240773
|
+
if (isHumanActorId(auth.actor)) return { kind: "human", actor: auth.actor };
|
|
240774
|
+
const currentSessionId = auth.dispatch?.chatSessionId;
|
|
240775
|
+
if (!currentSessionId) return null;
|
|
240776
|
+
const current = await getSession(currentSessionId);
|
|
240777
|
+
if (!current || current.aiActorId !== auth.actor) return null;
|
|
240778
|
+
return { kind: "agent", actor: auth.actor, humanActorId: current.humanActorId, currentSessionId };
|
|
240779
|
+
}
|
|
240780
|
+
function canReadChatHistory(viewer, session) {
|
|
240781
|
+
if (viewer.kind === "human") return session.humanActorId === viewer.actor;
|
|
240782
|
+
return session.aiActorId === viewer.actor && session.humanActorId === viewer.humanActorId;
|
|
240783
|
+
}
|
|
240784
|
+
function parseChatHistoryQuery(q2) {
|
|
240785
|
+
const before = Number(q2?.get("beforeSeq") ?? "");
|
|
240786
|
+
const limitRaw = Number(q2?.get("limit") ?? "");
|
|
240787
|
+
const limit = Number.isFinite(limitRaw) && limitRaw > 0 ? Math.min(Math.floor(limitRaw), CHAT_HISTORY_MAX_LIMIT) : CHAT_HISTORY_DEFAULT_LIMIT;
|
|
240788
|
+
const search2 = q2?.get("search")?.trim();
|
|
240789
|
+
return {
|
|
240790
|
+
...Number.isFinite(before) && before > 0 ? { beforeSeq: Math.floor(before) } : {},
|
|
240791
|
+
limit,
|
|
240792
|
+
...search2 ? { search: search2 } : {}
|
|
240793
|
+
};
|
|
240794
|
+
}
|
|
240795
|
+
function toChatHistoryView(session, page) {
|
|
240796
|
+
const messages = page.messages.map((m2) => {
|
|
240797
|
+
const names = (m2.attachments ?? []).map((a) => a.name).filter(Boolean);
|
|
240798
|
+
return {
|
|
240799
|
+
id: m2.id,
|
|
240800
|
+
seq: m2.seq,
|
|
240801
|
+
role: m2.role,
|
|
240802
|
+
content: m2.role === "user" ? stripInjectedChatContext(m2.content) : m2.role === "assistant" && m2.status === "error" ? markUnfinishedAssistant(m2.content) : m2.content,
|
|
240803
|
+
createdAt: m2.createdAt,
|
|
240804
|
+
...names.length ? { attachments: names } : {}
|
|
240805
|
+
};
|
|
240806
|
+
});
|
|
240807
|
+
return {
|
|
240808
|
+
sessionId: session.id,
|
|
240809
|
+
title: session.title,
|
|
240810
|
+
messages,
|
|
240811
|
+
hasMoreBefore: page.hasMoreBefore,
|
|
240812
|
+
nextBeforeSeq: page.hasMoreBefore && messages.length ? messages[0].seq : null
|
|
240813
|
+
};
|
|
240814
|
+
}
|
|
240815
|
+
function toChatHistorySessionList(viewer, sessions) {
|
|
240816
|
+
return sessions.filter((s2) => s2.visibility !== "internal" && canReadChatHistory(viewer, s2)).sort((a, b2) => b2.touchedAt.localeCompare(a.touchedAt)).map((s2) => ({
|
|
240817
|
+
id: s2.id,
|
|
240818
|
+
title: s2.title,
|
|
240819
|
+
createdAt: s2.createdAt,
|
|
240820
|
+
touchedAt: s2.touchedAt,
|
|
240821
|
+
projectId: s2.projectId ?? null,
|
|
240822
|
+
current: viewer.kind === "agent" && s2.id === viewer.currentSessionId
|
|
240823
|
+
}));
|
|
240824
|
+
}
|
|
240825
|
+
var CHAT_HISTORY_DEFAULT_LIMIT, CHAT_HISTORY_MAX_LIMIT;
|
|
240826
|
+
var init_agent_history = __esm({
|
|
240827
|
+
"../server/src/domains/chat-sessions/agent-history.ts"() {
|
|
240828
|
+
"use strict";
|
|
240829
|
+
init_src();
|
|
240830
|
+
init_continuation3();
|
|
240831
|
+
init_injected_context();
|
|
240832
|
+
CHAT_HISTORY_DEFAULT_LIMIT = 20;
|
|
240833
|
+
CHAT_HISTORY_MAX_LIMIT = 100;
|
|
240834
|
+
}
|
|
240835
|
+
});
|
|
240836
|
+
|
|
240741
240837
|
// ../server/src/domains/chat-sessions/project-bundle.ts
|
|
240742
240838
|
async function buildChatProjectBundle(projectId2, projects, readBlob) {
|
|
240743
240839
|
const project = await projects.getProject(projectId2);
|
|
@@ -241068,6 +241164,26 @@ function createChatSessionsDomain(opts) {
|
|
|
241068
241164
|
await store2.createSession(session);
|
|
241069
241165
|
return { status: 201, body: session };
|
|
241070
241166
|
});
|
|
241167
|
+
router.get("/api/chat-history", async (req) => {
|
|
241168
|
+
const store2 = await storeFor(req);
|
|
241169
|
+
const viewer = await resolveChatHistoryViewer(req.auth, (id) => store2.getSession(id));
|
|
241170
|
+
if (!viewer) return { status: 200, body: { items: [] } };
|
|
241171
|
+
const owner = viewer.kind === "human" ? viewer.actor : viewer.humanActorId;
|
|
241172
|
+
return { status: 200, body: { items: toChatHistorySessionList(viewer, await store2.listSessions(owner)) } };
|
|
241173
|
+
});
|
|
241174
|
+
router.get("/api/chat-history/:id", async (req) => {
|
|
241175
|
+
const store2 = await storeFor(req);
|
|
241176
|
+
const [viewer, session] = await Promise.all([
|
|
241177
|
+
resolveChatHistoryViewer(req.auth, (id) => store2.getSession(id)),
|
|
241178
|
+
store2.getSession(req.params.id)
|
|
241179
|
+
]);
|
|
241180
|
+
if (!viewer || !session || !canReadChatHistory(viewer, session)) {
|
|
241181
|
+
throw new ApiError(404, "NOT_FOUND", "session not found");
|
|
241182
|
+
}
|
|
241183
|
+
const query = parseChatHistoryQuery(req.query);
|
|
241184
|
+
const page = store2.listHistoryPage ? await store2.listHistoryPage(session.id, query) : pageChatHistory(await store2.listMessages(session.id), query);
|
|
241185
|
+
return { status: 200, body: toChatHistoryView(session, page) };
|
|
241186
|
+
});
|
|
241071
241187
|
router.get("/api/chat-sessions/by-runtime/:rt", async (req) => {
|
|
241072
241188
|
const store2 = await storeFor(req);
|
|
241073
241189
|
const session = await store2.getSessionByRuntimeSessionId(req.params.rt);
|
|
@@ -241761,6 +241877,7 @@ var init_chat_sessions2 = __esm({
|
|
|
241761
241877
|
init_service3();
|
|
241762
241878
|
init_reply_anchors();
|
|
241763
241879
|
init_injected_context();
|
|
241880
|
+
init_agent_history();
|
|
241764
241881
|
init_deletion();
|
|
241765
241882
|
init_chat_turn_gate();
|
|
241766
241883
|
init_company_data_store_router();
|
|
@@ -254675,6 +254792,35 @@ var init_postgres_chat_sessions = __esm({
|
|
|
254675
254792
|
);
|
|
254676
254793
|
return { messages: r.rows.map(rowToMessage), hasMoreBefore: older.rows.length > 0 };
|
|
254677
254794
|
}
|
|
254795
|
+
async listHistoryPage(sessionId, query) {
|
|
254796
|
+
if (!await this.scopedSessionExists(sessionId)) return { messages: [], hasMoreBefore: false };
|
|
254797
|
+
const limit = Math.max(0, Math.floor(query.limit));
|
|
254798
|
+
if (limit === 0) return { messages: [], hasMoreBefore: false };
|
|
254799
|
+
const args = [sessionId];
|
|
254800
|
+
const where = [
|
|
254801
|
+
"session_id = $1",
|
|
254802
|
+
"(role <> 'system' OR needs_agent_delivery IS TRUE)",
|
|
254803
|
+
"(role <> 'assistant' OR status IS DISTINCT FROM 'running')"
|
|
254804
|
+
];
|
|
254805
|
+
if (query.beforeSeq !== void 0) {
|
|
254806
|
+
args.push(query.beforeSeq);
|
|
254807
|
+
where.push(`seq < $${args.length}`);
|
|
254808
|
+
}
|
|
254809
|
+
const needle = query.search?.trim();
|
|
254810
|
+
if (needle) {
|
|
254811
|
+
args.push(`%${needle.replace(/[\\%_]/g, (c) => `\\${c}`)}%`);
|
|
254812
|
+
where.push(`content ILIKE $${args.length} ESCAPE '\\'`);
|
|
254813
|
+
}
|
|
254814
|
+
args.push(limit + 1);
|
|
254815
|
+
const r = await this.pool.query(
|
|
254816
|
+
`SELECT id, session_id, role, content, seq, created_at, run_id, turn_id, attachments, status, completed_at,
|
|
254817
|
+
message_key, needs_agent_delivery, delivered_to_agent_at, delivery_route
|
|
254818
|
+
FROM ${this.s}.chat_messages WHERE ${where.join(" AND ")} ORDER BY seq DESC LIMIT $${args.length}`,
|
|
254819
|
+
args
|
|
254820
|
+
);
|
|
254821
|
+
const rows = r.rows.map(rowToMessage);
|
|
254822
|
+
return { messages: rows.slice(0, limit).reverse(), hasMoreBefore: rows.length > limit };
|
|
254823
|
+
}
|
|
254678
254824
|
async listRunningAssistantMessages() {
|
|
254679
254825
|
const r = await this.pool.query(
|
|
254680
254826
|
`SELECT m.* FROM ${this.s}.chat_messages m
|
|
@@ -276134,6 +276280,24 @@ var COMMAND_DECLS = {
|
|
|
276134
276280
|
],
|
|
276135
276281
|
examples: ["oasis mem-delete mem-abc"]
|
|
276136
276282
|
},
|
|
276283
|
+
"chat-history": {
|
|
276284
|
+
group: "\u957F\u671F\u8BB0\u5FC6\uFF08ADR-0084/0102\uFF09",
|
|
276285
|
+
usage: "oasis chat-history [<\u4F1A\u8BDDid>] [--before <seq>] [--limit <n>] [--search <\u5173\u952E\u8BCD>] | oasis chat-history --sessions",
|
|
276286
|
+
description: "\u56DE\u8BFB\u5BF9\u8BDD\u5386\u53F2\uFF1A\u6362 runtime \u7EED\u8DD1\u65F6\u53EA\u5E26\u6700\u8FD1 20 \u6761\uFF0C\u66F4\u65E9\u7684\u7528\u5B83\u6309\u9700\u53D6\u3002\u7F3A\u7701\u8BFB\u5F53\u524D\u4F1A\u8BDD\uFF1B\u4E5F\u80FD\u8BFB\u4F60\u81EA\u5DF1\u548C\u540C\u4E00\u4E2A\u4EBA\u7684\u5176\u5B83\u4F1A\u8BDD\uFF08--sessions \u5217\u51FA\uFF09\u3002",
|
|
276287
|
+
positional: [{ name: "[<\u4F1A\u8BDDid>]", required: false, desc: "\u4F1A\u8BDD id\uFF1B\u7F3A\u7701 = \u5F53\u524D\u4F1A\u8BDD\uFF08$OASIS_CHAT_SESSION_ID\uFF09" }],
|
|
276288
|
+
flags: [
|
|
276289
|
+
{ name: "before", desc: "\u53EA\u770B seq \u5C0F\u4E8E\u5B83\u7684\uFF08\u5F80\u524D\u7FFB\u9875\uFF1B\u4E0A\u4E00\u9875\u672B\u5C3E\u4F1A\u7ED9\u51FA\u4E0B\u4E00\u9875\u7684\u547D\u4EE4\uFF09" },
|
|
276290
|
+
{ name: "limit", desc: "\u6761\u6570\uFF08\u9ED8\u8BA4 20\uFF0C\u4E0A\u9650 100\uFF09" },
|
|
276291
|
+
{ name: "search", desc: "\u6B63\u6587\u5173\u952E\u8BCD\uFF08\u4E0D\u533A\u5206\u5927\u5C0F\u5199\uFF09\uFF0C\u5728\u6574\u6BB5\u5BF9\u8BDD\u91CC\u641C" },
|
|
276292
|
+
{ name: "sessions", desc: "\u5217\u51FA\u4F60\u80FD\u56DE\u8BFB\u7684\u4F1A\u8BDD\uFF08id / \u6700\u8FD1\u6D3B\u52A8 / \u6807\u9898\uFF09", boolean: true }
|
|
276293
|
+
],
|
|
276294
|
+
examples: [
|
|
276295
|
+
"oasis chat-history --before 120",
|
|
276296
|
+
"oasis chat-history --search \u4EFB\u52A1\u4E66",
|
|
276297
|
+
"oasis chat-history --sessions",
|
|
276298
|
+
"oasis chat-history 84f48795-1c2d-4e5f-8a9b-0c1d2e3f4a5b --limit 50"
|
|
276299
|
+
]
|
|
276300
|
+
},
|
|
276137
276301
|
// —— 生命周期 ——
|
|
276138
276302
|
stale: {
|
|
276139
276303
|
group: "\u751F\u547D\u5468\u671F",
|
|
@@ -277277,6 +277441,35 @@ var ApiRequestError = class extends Error {
|
|
|
277277
277441
|
this.name = "ApiRequestError";
|
|
277278
277442
|
}
|
|
277279
277443
|
};
|
|
277444
|
+
var CHAT_HISTORY_SPEAKER = { user: "\u7528\u6237", assistant: "\u52A9\u624B", system: "\u7CFB\u7EDF" };
|
|
277445
|
+
function renderChatHistory(view, search2) {
|
|
277446
|
+
const lines = [];
|
|
277447
|
+
const scope2 = search2 ? `\u5339\u914D\u300C${search2}\u300D\u7684` : "";
|
|
277448
|
+
if (view.messages.length === 0) {
|
|
277449
|
+
lines.push(search2 ? `\u4F1A\u8BDD ${view.sessionId} \u91CC\u6CA1\u6709${scope2}\u6D88\u606F\u3002` : `\u4F1A\u8BDD ${view.sessionId} \u6CA1\u6709\u66F4\u65E9\u7684\u5BF9\u8BDD\u4E86\u3002`);
|
|
277450
|
+
return lines.join("\n");
|
|
277451
|
+
}
|
|
277452
|
+
const first = view.messages[0].seq;
|
|
277453
|
+
const last = view.messages[view.messages.length - 1].seq;
|
|
277454
|
+
lines.push(`\u4F1A\u8BDD ${view.sessionId}${view.title ? `\u300C${view.title}\u300D` : ""}\uFF1A${scope2}${view.messages.length} \u6761\uFF08#${first}\u2013#${last}\uFF0C\u6309\u65F6\u95F4\u987A\u5E8F\uFF09`);
|
|
277455
|
+
for (const m2 of view.messages) {
|
|
277456
|
+
lines.push("", `\u2500\u2500 #${m2.seq} ${CHAT_HISTORY_SPEAKER[m2.role]} \xB7 ${m2.createdAt.slice(0, 16).replace("T", " ")}`);
|
|
277457
|
+
if (m2.attachments?.length) lines.push(`\uFF08\u9644\u4EF6\uFF1A${m2.attachments.join("\u3001")}\uFF09`);
|
|
277458
|
+
lines.push(m2.content);
|
|
277459
|
+
}
|
|
277460
|
+
lines.push("");
|
|
277461
|
+
lines.push(view.nextBeforeSeq !== null ? `\u66F4\u65E9\u8FD8\u6709\uFF1Aoasis chat-history ${view.sessionId} --before ${view.nextBeforeSeq}${search2 ? ` --search ${JSON.stringify(search2)}` : ""}` : `\uFF08${scope2}\u5BF9\u8BDD\u5DF2\u7ECF\u5230\u5934\u4E86\uFF09`);
|
|
277462
|
+
return lines.join("\n");
|
|
277463
|
+
}
|
|
277464
|
+
function renderChatHistorySessions(items) {
|
|
277465
|
+
if (items.length === 0) return "\u6CA1\u6709\u53EF\u56DE\u8BFB\u7684\u4F1A\u8BDD\uFF08\u4E0D\u5728\u5BF9\u8BDD\u91CC\u8FD0\u884C\u65F6\uFF0Cagent \u8BFB\u4E0D\u5230\u4EFB\u4F55\u4F1A\u8BDD\uFF09\u3002";
|
|
277466
|
+
return [
|
|
277467
|
+
`\u53EF\u56DE\u8BFB\u7684\u4F1A\u8BDD ${items.length} \u6761\uFF08\u6700\u8FD1\u6D3B\u52A8\u5728\u524D\uFF09\uFF1A`,
|
|
277468
|
+
...items.map((s2) => `${s2.id} ${s2.touchedAt.slice(0, 16).replace("T", " ")} ${s2.title ?? "\uFF08\u65E0\u6807\u9898\uFF09"}${s2.current ? " \u2190 \u5F53\u524D\u4F1A\u8BDD" : ""}`),
|
|
277469
|
+
"",
|
|
277470
|
+
"\u8BFB\u5176\u4E2D\u4E00\u6761\uFF1Aoasis chat-history <\u4F1A\u8BDDid>"
|
|
277471
|
+
].join("\n");
|
|
277472
|
+
}
|
|
277280
277473
|
var ASYNC_AUTH_MESSAGE = "\u5DF2\u63D0\u4EA4\u4EBA\u5DE5\u5BA1\u6838\uFF1B\u5148\u53BB\u505A\u522B\u7684\uFF0C\u6CA1\u6709\u5C31\u6536\u5C3E\u2014\u2014\u6279\u51C6\u540E\u7CFB\u7EDF\u4F1A\u91CD\u65B0\u53EB\u4F60\u3002";
|
|
277281
277474
|
function asyncAuthorizationReturn(data) {
|
|
277282
277475
|
return data !== void 0 ? { message: ASYNC_AUTH_MESSAGE, data } : { message: ASYNC_AUTH_MESSAGE };
|
|
@@ -279365,6 +279558,28 @@ ${res.warning}`);
|
|
|
279365
279558
|
}
|
|
279366
279559
|
break;
|
|
279367
279560
|
}
|
|
279561
|
+
case "chat-history": {
|
|
279562
|
+
if (flags.has("sessions")) {
|
|
279563
|
+
const { items } = await api.request("GET", "/api/chat-history");
|
|
279564
|
+
println(renderChatHistorySessions(items));
|
|
279565
|
+
break;
|
|
279566
|
+
}
|
|
279567
|
+
const sid = positional[0] ?? process.env["OASIS_CHAT_SESSION_ID"];
|
|
279568
|
+
if (!sid) throw new Error("\u7528\u6CD5\uFF1Aoasis chat-history [<\u4F1A\u8BDDid>] \u2014\u2014\u4E0D\u5728\u5BF9\u8BDD\u91CC\u8FD0\u884C\u65F6\u8981\u7ED9\u4F1A\u8BDD id\uFF08oasis chat-history --sessions \u53EF\u5217\u51FA\uFF09");
|
|
279569
|
+
const qs = new URLSearchParams();
|
|
279570
|
+
const before = flags.get("before");
|
|
279571
|
+
const limit = flags.get("limit");
|
|
279572
|
+
const search2 = flags.get("search");
|
|
279573
|
+
if (before) qs.set("beforeSeq", before);
|
|
279574
|
+
if (limit) qs.set("limit", limit);
|
|
279575
|
+
if (search2) qs.set("search", search2);
|
|
279576
|
+
const view = await api.request(
|
|
279577
|
+
"GET",
|
|
279578
|
+
`/api/chat-history/${encodeURIComponent(sid)}${qs.size ? `?${qs.toString()}` : ""}`
|
|
279579
|
+
);
|
|
279580
|
+
println(renderChatHistory(view, search2));
|
|
279581
|
+
break;
|
|
279582
|
+
}
|
|
279368
279583
|
case "mem-delete": {
|
|
279369
279584
|
const memId = needPos(positional, 0, "oasis mem-delete <memId>");
|
|
279370
279585
|
await api.request("DELETE", `/api/actor-memory/${encodeURIComponent(memId)}`);
|
|
@@ -280911,7 +281126,7 @@ function shimScript() {
|
|
|
280911
281126
|
}
|
|
280912
281127
|
|
|
280913
281128
|
// src/index.ts
|
|
280914
|
-
var PKG_VERSION = true ? "2.2.
|
|
281129
|
+
var PKG_VERSION = true ? "2.2.52" : "dev";
|
|
280915
281130
|
var LOCAL_BIN = localBin();
|
|
280916
281131
|
var NPM_PREFIX = npmPrefix();
|
|
280917
281132
|
var INSTANCE = DEFAULT_INSTANCE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oasis_test_v2",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.52",
|
|
4
4
|
"description": "Oasis node daemon + CLI — background daemon, auto-start, full server CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oasis": "./dist/index.js"
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"oasisRelease": {
|
|
29
|
-
"sourceHead": "
|
|
29
|
+
"sourceHead": "947e60bf5ac5d7ade7d88ea73fc0dd6dcb8ecd96"
|
|
30
30
|
}
|
|
31
31
|
}
|