@teammy/server 0.2.18 → 0.2.19
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/main.js +461 -233
- package/dist/web/assets/Assistant-BAhJ1B8n.js +1 -0
- package/dist/web/assets/{Computers-DAf8sobH.css → Computers-CBnQX-2p.css} +1 -1
- package/dist/web/assets/Computers-hHQYztG9.js +13 -0
- package/dist/web/assets/{Conversation-DN9pVRsf.js → Conversation-Bdsoobmv.js} +1 -1
- package/dist/web/assets/{Dashboard-B0Dj-KMg.js → Dashboard-De-8jlcE.js} +1 -1
- package/dist/web/assets/Dropdown-Dh9Q9fSi.js +55 -0
- package/dist/web/assets/{Files-B-iLyRvj.js → Files-DYc1q61J.js} +1 -1
- package/dist/web/assets/{Help-B21pS1RH.js → Help-DHZAzK6c.js} +13 -6
- package/dist/web/assets/{Markdown-Bh1l6OQM.js → Markdown-Gk89fXoh.js} +2 -2
- package/dist/web/assets/{MessageComposer-D9vqKUX5.js → MessageComposer-DFvWZibH.js} +1 -1
- package/dist/web/assets/{ResourceLibrary-qg568G4m.js → ResourceLibrary-DYwZzWyh.js} +3 -3
- package/dist/web/assets/{TerminalPane-hEQVsy4e.js → TerminalPane-ZhM38vie.js} +1 -1
- package/dist/web/assets/{WorkspaceTree-BMZWhAXJ.js → WorkspaceTree-yST2ByxM.js} +1 -1
- package/dist/web/assets/{file-links-DvISesr0.js → file-links-CtHFx6cd.js} +1 -1
- package/dist/web/assets/index-CWjsEUUy.js +10 -0
- package/dist/web/assets/{task-links-BeRoF5ff.js → task-links-ArhNpuGG.js} +1 -1
- package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/Assistant-CfsrbTdh.js +0 -1
- package/dist/web/assets/Computers-CdwUaH3q.js +0 -13
- package/dist/web/assets/Dropdown-Cz5xKbpV.js +0 -55
- package/dist/web/assets/index-_W-pw3aC.js +0 -10
package/dist/main.js
CHANGED
|
@@ -534,7 +534,7 @@ var SessionActivitySchema = z5.object({
|
|
|
534
534
|
durationMs: z5.number().finite().nonnegative().optional(),
|
|
535
535
|
// A native turn can end while the work is still waiting for a reply.
|
|
536
536
|
// Null marks that distinction; older clients omit the result altogether.
|
|
537
|
-
completedWork: z5.object({ preview: z5.string().max(previewLength * 2) }).nullable().optional()
|
|
537
|
+
completedWork: z5.object({ preview: z5.string().max(previewLength * 2), answer: z5.string().optional() }).nullable().optional()
|
|
538
538
|
});
|
|
539
539
|
var LocalSessionMessageSchema = z5.object({
|
|
540
540
|
queue: z5.object({
|
|
@@ -565,9 +565,15 @@ var LocalSessionMessageSchema = z5.object({
|
|
|
565
565
|
questions: z5.array(InteractionPartSchema)
|
|
566
566
|
}).nullable()
|
|
567
567
|
});
|
|
568
|
+
var sessionMessagePageSize = 60;
|
|
569
|
+
function questionNeedsAnswer(question) {
|
|
570
|
+
return question.state === "pending" && (!question.response || ["human_routed", "failed", "handled"].includes(question.submissionState ?? ""));
|
|
571
|
+
}
|
|
568
572
|
var LocalSessionChatSchema = z5.object({
|
|
569
573
|
canRewind: z5.boolean().default(false),
|
|
570
574
|
cursor: z5.number().int(),
|
|
575
|
+
olderBefore: z5.number().int().positive().nullable().default(null),
|
|
576
|
+
pendingQuestions: z5.array(z5.object({ id: z5.string(), seq: z5.number().int() })).optional(),
|
|
571
577
|
session: LocalSessionSchema,
|
|
572
578
|
messages: z5.array(LocalSessionMessageSchema),
|
|
573
579
|
commands: z5.array(SessionCommandSchema)
|
|
@@ -6794,13 +6800,16 @@ function validateRewind(hub, identity, session, argument) {
|
|
|
6794
6800
|
(row) => row.state !== "uncertain" || JSON.parse(String(row.argument)).messageId !== value.messageId
|
|
6795
6801
|
))
|
|
6796
6802
|
throw new HubError(409, "REWIND_PENDING", "\u4E0A\u6B21\u56DE\u9000\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u4ECE\u539F\u7F16\u8F91\u4F4D\u7F6E\u91CD\u8BD5\u3002");
|
|
6797
|
-
const
|
|
6798
|
-
"SELECT
|
|
6799
|
-
).
|
|
6800
|
-
const target2 = rows.find((r) => r.id === value.messageId);
|
|
6803
|
+
const target2 = hub.db.prepare(
|
|
6804
|
+
"SELECT role FROM member_session_messages WHERE project_id=? AND member_id=? AND session_id=? AND id=? AND superseded_by IS NULL"
|
|
6805
|
+
).get(identity.workspaceId, identity.memberId, session.id, value.messageId);
|
|
6801
6806
|
if (!target2 || target2.role !== "user" || !value.messageId.startsWith("input:"))
|
|
6802
6807
|
throw new HubError(400, "REWIND_TARGET", "\u8BF7\u9009\u62E9\u5F53\u524D\u4F1A\u8BDD\u4E2D\u7684\u7528\u6237\u6D88\u606F\u3002");
|
|
6803
|
-
|
|
6808
|
+
const sessions2 = new MemberSessions(hub);
|
|
6809
|
+
let page = sessions2.chat(identity, session.id);
|
|
6810
|
+
while (!page.messages.length && page.olderBefore !== null)
|
|
6811
|
+
page = sessions2.chat(identity, session.id, { before: page.olderBefore });
|
|
6812
|
+
if (page.messages.at(-1)?.id !== value.expectedLastMessage)
|
|
6804
6813
|
throw new HubError(409, "REWIND_CHANGED", "\u4F1A\u8BDD\u5DF2\u6709\u65B0\u6D88\u606F\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u7F16\u8F91\u4F4D\u7F6E\u3002");
|
|
6805
6814
|
const input = new MemberExecution(hub).input(identity, value.messageId.slice(6));
|
|
6806
6815
|
if (input.interaction || input.source.type !== "web_session")
|
|
@@ -6845,6 +6854,34 @@ function completeRewind(hub, identity, session, commandId, argument, result) {
|
|
|
6845
6854
|
});
|
|
6846
6855
|
}
|
|
6847
6856
|
|
|
6857
|
+
// apps/server/member-execution/transcript.ts
|
|
6858
|
+
function transcriptPage(hub, identity, session, window) {
|
|
6859
|
+
const scope2 = [identity.workspaceId, identity.memberId, session];
|
|
6860
|
+
const filter2 = "m.project_id=? AND m.member_id=? AND m.session_id=? AND m.superseded_by IS NULL";
|
|
6861
|
+
const select = `SELECT m.*,i.state input_state,i.id input_id,i.read_at input_read_at,i.payload_json,
|
|
6862
|
+
q.id question_id,q.code,q.state question_state,q.content_json FROM member_session_messages m
|
|
6863
|
+
LEFT JOIN member_agent_inputs i ON m.role='user' AND i.id=substr(m.id,7) AND m.id='input:'||i.id
|
|
6864
|
+
LEFT JOIN member_agent_questions q ON q.id=m.id WHERE ${filter2}`;
|
|
6865
|
+
const range = (from) => {
|
|
6866
|
+
const rows2 = hub.db.prepare(select + " AND m.seq>=? ORDER BY m.seq").all(...scope2, from);
|
|
6867
|
+
const older = hub.db.prepare(`SELECT 1 FROM member_session_messages m WHERE ${filter2} AND m.seq<? LIMIT 1`).get(...scope2, from);
|
|
6868
|
+
return { rows: rows2, olderBefore: older ? from : null };
|
|
6869
|
+
};
|
|
6870
|
+
if (window.from !== void 0) return range(window.from);
|
|
6871
|
+
const rows = hub.db.prepare(select + " AND m.seq<? ORDER BY m.seq DESC LIMIT ?").all(...scope2, window.before ?? Number.MAX_SAFE_INTEGER, sessionMessagePageSize + 1);
|
|
6872
|
+
const hasOlder = rows.length > sessionMessagePageSize;
|
|
6873
|
+
if (hasOlder) rows.pop();
|
|
6874
|
+
rows.reverse();
|
|
6875
|
+
const olderBefore = hasOlder ? Number(rows[0].seq) : null;
|
|
6876
|
+
if (window.question && olderBefore !== null) {
|
|
6877
|
+
const target2 = hub.db.prepare(
|
|
6878
|
+
`SELECT m.seq FROM member_session_messages m JOIN member_agent_questions q ON q.id=m.id WHERE ${filter2} AND m.id=?`
|
|
6879
|
+
).get(...scope2, window.question);
|
|
6880
|
+
if (target2 && Number(target2.seq) < olderBefore) return range(Number(target2.seq));
|
|
6881
|
+
}
|
|
6882
|
+
return { rows, olderBefore };
|
|
6883
|
+
}
|
|
6884
|
+
|
|
6848
6885
|
// apps/server/member-execution/sessions.ts
|
|
6849
6886
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
6850
6887
|
import { z as z25 } from "zod";
|
|
@@ -7303,20 +7340,48 @@ var MemberSessions = class {
|
|
|
7303
7340
|
this.hub.db.prepare("UPDATE member_agent_sessions SET activity_at=? WHERE project_id=? AND id=?").run((/* @__PURE__ */ new Date()).toISOString(), identity.workspaceId, session);
|
|
7304
7341
|
return !!written.changes;
|
|
7305
7342
|
}
|
|
7306
|
-
|
|
7343
|
+
eventCursor(identity, id) {
|
|
7344
|
+
const row = this.hub.db.prepare(
|
|
7345
|
+
`SELECT (SELECT COALESCE(MAX(seq),0) FROM member_session_events WHERE project_id=s.project_id AND session_id=s.id) seq
|
|
7346
|
+
FROM member_agent_sessions s WHERE s.project_id=? AND s.member_id=? AND s.id=?`
|
|
7347
|
+
).get(identity.workspaceId, identity.memberId, id);
|
|
7348
|
+
if (!row) throw new HubError(404, "SESSION_NOT_FOUND", "\u627E\u4E0D\u5230\u672C\u4EBA\u7684\u4F1A\u8BDD\u3002");
|
|
7349
|
+
return Number(row.seq);
|
|
7350
|
+
}
|
|
7351
|
+
chat(identity, id, window = {}) {
|
|
7352
|
+
const cursor = this.eventCursor(identity, id);
|
|
7307
7353
|
const session = this.get(identity, id);
|
|
7308
|
-
const rows = this.hub
|
|
7309
|
-
`SELECT m.*,i.state input_state,i.id input_id,i.read_at input_read_at,i.payload_json,q.id question_id,q.code,q.state question_state,q.content_json FROM member_session_messages m
|
|
7310
|
-
LEFT JOIN member_agent_inputs i ON 'input:'||i.id=m.id LEFT JOIN member_agent_questions q ON q.id=m.id
|
|
7311
|
-
WHERE m.project_id=? AND m.member_id=? AND m.session_id=? AND m.superseded_by IS NULL ORDER BY m.seq`
|
|
7312
|
-
).all(identity.workspaceId, identity.memberId, id);
|
|
7354
|
+
const { rows, olderBefore } = transcriptPage(this.hub, identity, id, window);
|
|
7313
7355
|
const replies = /* @__PURE__ */ new Map();
|
|
7314
|
-
const
|
|
7315
|
-
rows.filter((
|
|
7356
|
+
const inputs = new Map(
|
|
7357
|
+
rows.filter((r) => r.input_id).map((r) => [String(r.input_id), JSON.parse(String(r.payload_json))])
|
|
7358
|
+
);
|
|
7359
|
+
const questionIds = rows.flatMap((r) => r.question_id ? [String(r.question_id)] : []);
|
|
7360
|
+
for (const input of inputs.values())
|
|
7361
|
+
if (input.interaction?.action === "answer") questionIds.push(input.interaction.question);
|
|
7362
|
+
const questionRows = this.hub.db.prepare(
|
|
7363
|
+
`SELECT q.id question_id,q.content_json,q.state,m.seq
|
|
7364
|
+
FROM member_agent_questions q JOIN member_session_messages m ON m.id=q.id
|
|
7365
|
+
WHERE q.project_id=? AND q.member_id=? AND m.session_id=? AND m.superseded_by IS NULL AND
|
|
7366
|
+
(q.state='pending' OR q.id IN (SELECT value FROM json_each(?))
|
|
7367
|
+
OR json_extract(q.content_json,'$.response.inputId') IN (SELECT value FROM json_each(?))) ORDER BY m.seq`
|
|
7368
|
+
).all(
|
|
7369
|
+
identity.workspaceId,
|
|
7370
|
+
identity.memberId,
|
|
7371
|
+
id,
|
|
7372
|
+
JSON.stringify(questionIds),
|
|
7373
|
+
JSON.stringify([...inputs.keys()])
|
|
7316
7374
|
);
|
|
7375
|
+
const questions = new Map(questionRows.map((row) => [row.question_id, row]));
|
|
7317
7376
|
const folded = /* @__PURE__ */ new Set();
|
|
7318
|
-
|
|
7319
|
-
|
|
7377
|
+
const answerRows = questions.size ? this.hub.db.prepare(
|
|
7378
|
+
`SELECT i.id input_id,i.state input_state,i.payload_json
|
|
7379
|
+
FROM member_agent_inputs i JOIN member_session_messages m ON m.id='input:'||i.id
|
|
7380
|
+
WHERE i.project_id=? AND i.member_id=? AND json_extract(i.payload_json,'$.interaction.action')='answer'
|
|
7381
|
+
AND json_extract(i.payload_json,'$.interaction.question') IN (SELECT value FROM json_each(?))
|
|
7382
|
+
AND m.session_id=? AND m.superseded_by IS NULL ORDER BY m.seq`
|
|
7383
|
+
).all(identity.workspaceId, identity.memberId, JSON.stringify([...questions.keys()]), id) : [];
|
|
7384
|
+
for (const row of answerRows) {
|
|
7320
7385
|
const input = JSON.parse(String(row.payload_json));
|
|
7321
7386
|
if (input.source.type !== "web_session" || input.interaction?.action !== "answer") continue;
|
|
7322
7387
|
const question = questions.get(input.interaction.question);
|
|
@@ -7344,9 +7409,18 @@ var MemberSessions = class {
|
|
|
7344
7409
|
});
|
|
7345
7410
|
folded.add(String(row.input_id));
|
|
7346
7411
|
}
|
|
7347
|
-
|
|
7348
|
-
|
|
7412
|
+
const pendingQuestions = [];
|
|
7413
|
+
for (const row of questionRows) {
|
|
7414
|
+
const content = JSON.parse(String(row.content_json));
|
|
7415
|
+
const response = content.response;
|
|
7349
7416
|
if (response?.inputId) folded.add(response.inputId);
|
|
7417
|
+
const reply = replies.get(String(row.question_id));
|
|
7418
|
+
if (questionDelivery(content, session) === "async" && questionNeedsAnswer({
|
|
7419
|
+
state: String(row.state),
|
|
7420
|
+
response: response ?? reply?.response,
|
|
7421
|
+
submissionState: reply?.state
|
|
7422
|
+
}))
|
|
7423
|
+
pendingQuestions.push({ id: String(row.question_id), seq: Number(row.seq) });
|
|
7350
7424
|
}
|
|
7351
7425
|
const runtime = new MemberExecution(this.hub).runtime(identity, session.directory);
|
|
7352
7426
|
const runtimeConfig = JSON.parse(String(runtime?.config_json ?? "{}"));
|
|
@@ -7357,8 +7431,8 @@ var MemberSessions = class {
|
|
|
7357
7431
|
);
|
|
7358
7432
|
const queueInfo = (row) => {
|
|
7359
7433
|
if (!row.input_id || !row.payload_json) return {};
|
|
7360
|
-
const input =
|
|
7361
|
-
if (!input
|
|
7434
|
+
const input = inputs.get(String(row.input_id));
|
|
7435
|
+
if (!input?.delivery || input.source.type !== "web_session" || input.interaction) return {};
|
|
7362
7436
|
const queued = input.delivery === "queue";
|
|
7363
7437
|
const edit = queued ? this.hub.db.prepare("SELECT revision,cancelled FROM member_session_input_edits WHERE input_id=?").get(String(row.input_id)) : void 0;
|
|
7364
7438
|
const state = edit?.cancelled ? "cancelled" : progress.get(String(row.input_id))?.state ?? (row.input_read_at ? "handled" : row.input_state === "accepted" ? "queued" : String(row.input_state));
|
|
@@ -7375,6 +7449,7 @@ var MemberSessions = class {
|
|
|
7375
7449
|
};
|
|
7376
7450
|
};
|
|
7377
7451
|
const messages = rows.filter((row) => !row.input_id || !folded.has(String(row.input_id))).map((row) => {
|
|
7452
|
+
const input = inputs.get(String(row.input_id));
|
|
7378
7453
|
const content = row.question_id ? JSON.parse(String(row.content_json)) : null;
|
|
7379
7454
|
return {
|
|
7380
7455
|
...queueInfo(row),
|
|
@@ -7382,8 +7457,8 @@ var MemberSessions = class {
|
|
|
7382
7457
|
seq: Number(row.seq),
|
|
7383
7458
|
role: String(row.role),
|
|
7384
7459
|
body: String(row.body),
|
|
7385
|
-
...
|
|
7386
|
-
...
|
|
7460
|
+
...input?.attachments ? { attachments: input.attachments } : {},
|
|
7461
|
+
...input?.images ? { images: input.images } : {},
|
|
7387
7462
|
source: String(row.source),
|
|
7388
7463
|
state: String(row.input_state ?? row.state),
|
|
7389
7464
|
createdAt: String(row.created_at),
|
|
@@ -7406,14 +7481,11 @@ var MemberSessions = class {
|
|
|
7406
7481
|
} : null
|
|
7407
7482
|
};
|
|
7408
7483
|
});
|
|
7409
|
-
const cursor = Number(
|
|
7410
|
-
this.hub.db.prepare(
|
|
7411
|
-
"SELECT COALESCE(MAX(seq),0) seq FROM member_session_events WHERE project_id=? AND session_id=?"
|
|
7412
|
-
).get(identity.workspaceId, id).seq
|
|
7413
|
-
);
|
|
7414
7484
|
return {
|
|
7415
7485
|
session,
|
|
7416
7486
|
messages,
|
|
7487
|
+
olderBefore,
|
|
7488
|
+
pendingQuestions,
|
|
7417
7489
|
commands: this.commands(identity, id),
|
|
7418
7490
|
cursor,
|
|
7419
7491
|
canRewind: rewindAvailable(this.hub, identity, session)
|
|
@@ -7522,7 +7594,8 @@ var MemberSessions = class {
|
|
|
7522
7594
|
commands(identity, session) {
|
|
7523
7595
|
requireProjectActor(this.hub, identity);
|
|
7524
7596
|
return this.hub.db.prepare(
|
|
7525
|
-
`SELECT c
|
|
7597
|
+
`SELECT c.id,c.session_id,c.kind,c.argument,c.input_id,c.state,c.error
|
|
7598
|
+
FROM member_session_commands c JOIN member_agent_sessions s ON s.project_id=c.project_id AND s.id=c.session_id
|
|
7526
7599
|
JOIN member_agent_directories d ON d.project_id=s.project_id AND d.id=s.directory_id
|
|
7527
7600
|
WHERE c.project_id=? AND c.member_id=? AND (? IS NULL OR c.session_id=?) AND (? IS NULL OR d.device_id=?) ORDER BY c.rowid`
|
|
7528
7601
|
).all(
|
|
@@ -7605,6 +7678,16 @@ var MemberSessions = class {
|
|
|
7605
7678
|
if (!["queued", "running"].includes(String(row.state)) || row.instance && row.instance !== value.instance && value.state !== "uncertain")
|
|
7606
7679
|
throw new HubError(409, "COMMAND_OWNED", "\u64CD\u4F5C\u7ED3\u679C\u9700\u8981\u6838\u5BF9\uFF0C\u4E0D\u80FD\u91CD\u590D\u6267\u884C\u3002");
|
|
7607
7680
|
this.hub.db.prepare("UPDATE member_session_commands SET state=?,instance=?,error=? WHERE id=?").run(value.state, value.instance, value.error, id);
|
|
7681
|
+
if (row.kind === "stop" && (value.state === "running" || value.state === "succeeded")) {
|
|
7682
|
+
const report = JSON.parse(String(runtime.config_json));
|
|
7683
|
+
const input2 = runningSessionInput(report.sessions?.find((s) => s.id === row.session_id));
|
|
7684
|
+
if (value.state === "running" && input2)
|
|
7685
|
+
this.hub.db.prepare("UPDATE member_session_commands SET result_json=? WHERE id=?").run(JSON.stringify(input2), id);
|
|
7686
|
+
if (value.state === "succeeded" && (!row.result_json || !input2 || row.result_json === JSON.stringify(input2)))
|
|
7687
|
+
this.hub.db.prepare(
|
|
7688
|
+
"UPDATE member_agent_sessions SET state='idle' WHERE project_id=? AND id=? AND state IN ('working','waiting')"
|
|
7689
|
+
).run(identity.workspaceId, row.session_id);
|
|
7690
|
+
}
|
|
7608
7691
|
if (value.state === "succeeded") {
|
|
7609
7692
|
if (row.kind === "rewind") {
|
|
7610
7693
|
completeRewind(
|
|
@@ -8198,6 +8281,10 @@ function associateTaskFolders(hub, project, input) {
|
|
|
8198
8281
|
|
|
8199
8282
|
// apps/server/member-execution/store.ts
|
|
8200
8283
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
8284
|
+
function runningSessionInput(report) {
|
|
8285
|
+
if (report?.state !== "working" && report?.state !== "waiting") return;
|
|
8286
|
+
return report.inputs?.filter((i) => i.state === "running" || i.state === "dispatching").at(-1)?.id;
|
|
8287
|
+
}
|
|
8201
8288
|
var MemberExecution = class {
|
|
8202
8289
|
constructor(hub, now6 = Date.now) {
|
|
8203
8290
|
this.hub = hub;
|
|
@@ -8301,6 +8388,7 @@ var MemberExecution = class {
|
|
|
8301
8388
|
this.now() + 45e3,
|
|
8302
8389
|
JSON.stringify(value)
|
|
8303
8390
|
);
|
|
8391
|
+
let previousSessions;
|
|
8304
8392
|
for (const item of value.sessions ?? []) {
|
|
8305
8393
|
const session = new MemberSessions(this.hub).get(identity, item.id);
|
|
8306
8394
|
const dir = new MemberSessions(this.hub).directory(identity, session.directory);
|
|
@@ -8318,10 +8406,17 @@ var MemberExecution = class {
|
|
|
8318
8406
|
state: "succeeded"
|
|
8319
8407
|
});
|
|
8320
8408
|
}
|
|
8409
|
+
let state = item.state;
|
|
8410
|
+
const input2 = runningSessionInput(item);
|
|
8411
|
+
if (session.state === "idle" && input2 && current2?.instance === value.instance) {
|
|
8412
|
+
previousSessions ??= JSON.parse(String(current2.config_json)).sessions ?? [];
|
|
8413
|
+
if (runningSessionInput(previousSessions.find((s) => s.id === item.id)) === input2)
|
|
8414
|
+
state = "idle";
|
|
8415
|
+
}
|
|
8321
8416
|
this.hub.db.prepare(
|
|
8322
8417
|
"UPDATE member_agent_sessions SET state=?,applied_revision=?,effective_json=?,cwd=?,error=?,native_session=COALESCE(?,native_session) WHERE project_id=? AND id=?"
|
|
8323
8418
|
).run(
|
|
8324
|
-
|
|
8419
|
+
state,
|
|
8325
8420
|
item.appliedRevision,
|
|
8326
8421
|
item.effectiveConfig ? JSON.stringify(item.effectiveConfig) : null,
|
|
8327
8422
|
item.cwd,
|
|
@@ -9027,7 +9122,11 @@ function replyToRoutedRequest(hub, identity, input) {
|
|
|
9027
9122
|
return diagnosticTransaction(hub, () => {
|
|
9028
9123
|
const source = new MemberExecution(hub).input(identity, value.inputId);
|
|
9029
9124
|
if (source.source.type !== "routed.event" || source.state !== "accepted")
|
|
9030
|
-
throw new HubError(
|
|
9125
|
+
throw new HubError(
|
|
9126
|
+
403,
|
|
9127
|
+
"ROUTED_REQUEST_REQUIRED",
|
|
9128
|
+
"\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u6B64\u5DE5\u5177\u56DE\u5E94\u7684\u5DF2\u63A5\u624B\u4E8B\u4EF6\u3002\u666E\u901A\u4F1A\u8BDD\u8BF7\u76F4\u63A5\u7ED9\u51FA\u6700\u7EC8\u7B54\u590D\u3002"
|
|
9129
|
+
);
|
|
9031
9130
|
const row = hub.db.prepare("SELECT * FROM routing_requests WHERE id=? AND member_id=? AND input_id=?").get(source.source.ref, identity.memberId, source.id);
|
|
9032
9131
|
if (!row || row.handler !== "managed" || row.requires_human)
|
|
9033
9132
|
throw new HubError(403, "ROUTED_REQUEST_OWNER", "\u8BE5\u8BF7\u6C42\u4E0D\u7531\u5F53\u524D Agent \u56DE\u5E94\u3002");
|
|
@@ -9237,9 +9336,11 @@ var WecomStore = class {
|
|
|
9237
9336
|
computerCompletionCategory,
|
|
9238
9337
|
JSON.stringify([identity.workspaceId, session.id, turn.turnId]),
|
|
9239
9338
|
() => {
|
|
9240
|
-
|
|
9241
|
-
if (
|
|
9242
|
-
|
|
9339
|
+
if (turn.completedWork === null) return null;
|
|
9340
|
+
if (turn.completedWork === void 0 && this.legacyTurnWaiting(identity, input))
|
|
9341
|
+
return null;
|
|
9342
|
+
const answer = turn.completedWork?.answer ?? this.turnAnswer(identity, session, turn.turnId) ?? turn.completedWork?.preview;
|
|
9343
|
+
return "\u672C\u8F6E\u5DE5\u4F5C\u5DF2\u5B8C\u6210\u3002" + (answer ? "\n" + answer : "");
|
|
9243
9344
|
}
|
|
9244
9345
|
);
|
|
9245
9346
|
}
|
|
@@ -9266,35 +9367,36 @@ var WecomStore = class {
|
|
|
9266
9367
|
const directory = new MemberSessions(this.hub).directory(identity, session.directory);
|
|
9267
9368
|
const query2 = new URLSearchParams({ directory: session.directory, session: session.id });
|
|
9268
9369
|
if (category === computerQuestionCategory) query2.set("question", source);
|
|
9370
|
+
const base = new SiteRepository(this.hub).config().publicServerUrl;
|
|
9269
9371
|
const link4 = wecomLinks(
|
|
9270
9372
|
`[${category === computerQuestionCategory ? "\u67E5\u770B\u5E76\u5904\u7406" : "\u67E5\u770B\u4F1A\u8BDD"}](/projects/${encodeURIComponent(identity.workspaceId)}/computers?${query2})`,
|
|
9271
|
-
|
|
9373
|
+
base
|
|
9272
9374
|
);
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
}
|
|
9283
|
-
legacyTurnPreview(identity, session, turn, input) {
|
|
9284
|
-
const waiting = this.hub.db.prepare(
|
|
9375
|
+
const content = `${wecomLinkLabel(String(directory.name))} \xB7 ${wecomLinkLabel(session.title)}\uFF5C${wecomLinks(body, base)}`;
|
|
9376
|
+
const footer = "\n" + link4;
|
|
9377
|
+
const parts = wecomParts(content, 20480 - Buffer.byteLength(footer));
|
|
9378
|
+
parts[parts.length - 1] += footer;
|
|
9379
|
+
for (const [index, part] of parts.entries())
|
|
9380
|
+
this.queue(bot, external, category, index ? `${source}:${index}` : source, part, identity);
|
|
9381
|
+
}
|
|
9382
|
+
legacyTurnWaiting(identity, input) {
|
|
9383
|
+
return this.hub.db.prepare(
|
|
9285
9384
|
`SELECT 1 FROM member_agent_question_codes c LEFT JOIN member_agent_questions q ON q.id=c.id
|
|
9286
9385
|
WHERE c.project_id=? AND c.member_id=? AND c.reply_context=? AND
|
|
9287
9386
|
((q.id IS NULL AND c.reserved_after_input >= (SELECT seq FROM member_agent_inputs WHERE id=?)) OR
|
|
9288
9387
|
(q.state='pending' AND EXISTS (SELECT 1 FROM member_agent_message_inputs i WHERE i.operation_id=q.id AND i.input_id=?)))
|
|
9289
9388
|
LIMIT 1`
|
|
9290
9389
|
).get(identity.workspaceId, identity.memberId, input.replyContext, input.id, input.id);
|
|
9291
|
-
|
|
9390
|
+
}
|
|
9391
|
+
turnAnswer(identity, session, turn) {
|
|
9292
9392
|
const answer = this.hub.db.prepare(
|
|
9293
|
-
`SELECT body FROM member_session_messages
|
|
9294
|
-
|
|
9295
|
-
|
|
9393
|
+
`SELECT COALESCE(final.body,m.body) body FROM member_session_messages m
|
|
9394
|
+
LEFT JOIN member_agent_messages final ON final.operation_id=m.id
|
|
9395
|
+
WHERE m.project_id=? AND m.session_id=? AND m.superseded_by IS NULL
|
|
9396
|
+
AND m.role='assistant' AND m.state IN ('succeeded','sent') AND json_extract(m.activity_json,'$.kind')='answer'
|
|
9397
|
+
AND json_extract(m.activity_json,'$.turnId')=? ORDER BY m.seq DESC LIMIT 1`
|
|
9296
9398
|
).get(identity.workspaceId, session.id, turn);
|
|
9297
|
-
return
|
|
9399
|
+
return answer ? String(answer.body) : void 0;
|
|
9298
9400
|
}
|
|
9299
9401
|
subscribe(bot, external, code) {
|
|
9300
9402
|
const row = this.hub.db.prepare("SELECT * FROM wecom_codes WHERE code_hash=? AND bot_id=? AND expires_at>?").get(hash2(code.toUpperCase()), bot, Date.now());
|
|
@@ -9667,13 +9769,14 @@ var ExecutionBridge = class {
|
|
|
9667
9769
|
AND json_extract(activity_json,'$.turnId')=? LIMIT 1`
|
|
9668
9770
|
).get(identity.workspaceId, session.id, turn.turnId);
|
|
9669
9771
|
if (previous && previous.id !== value.operationId) return { ok: true };
|
|
9772
|
+
const activity = turn?.completedWork?.answer !== void 0 ? { ...turn, completedWork: { preview: turn.completedWork.preview } } : value.activity;
|
|
9670
9773
|
const written = sessions2.message(identity, session.id, {
|
|
9671
9774
|
id: value.operationId,
|
|
9672
9775
|
role: "assistant",
|
|
9673
9776
|
body: value.body,
|
|
9674
9777
|
source: "agent",
|
|
9675
9778
|
state: value.state,
|
|
9676
|
-
...
|
|
9779
|
+
...activity ? { activity } : {}
|
|
9677
9780
|
});
|
|
9678
9781
|
if (written && turn && !previous && turn.completedWork !== null)
|
|
9679
9782
|
new WecomStore(this.hub).queueComputerCompletion(identity, session, turn, source);
|
|
@@ -10265,12 +10368,13 @@ CREATE TABLE wecom_groups(bot_id TEXT NOT NULL,chat_id TEXT NOT NULL,project_id
|
|
|
10265
10368
|
CREATE TABLE wecom_group_requests(run_id TEXT PRIMARY KEY,bot_id TEXT NOT NULL,chat_id TEXT NOT NULL,project_id TEXT NOT NULL,user_id TEXT NOT NULL,collected INTEGER NOT NULL DEFAULT 0);
|
|
10266
10369
|
`;
|
|
10267
10370
|
var digest5 = (code) => createHash15("sha256").update(code.toUpperCase()).digest("hex");
|
|
10268
|
-
function wecomParts(text2) {
|
|
10371
|
+
function wecomParts(text2, maxBytes = 17e3) {
|
|
10372
|
+
if (Buffer.byteLength(text2) <= maxBytes) return text2 ? [text2] : [];
|
|
10269
10373
|
const parts = [];
|
|
10270
10374
|
let part = "", bytes3 = 0;
|
|
10271
10375
|
for (const char of text2) {
|
|
10272
10376
|
const size2 = Buffer.byteLength(char);
|
|
10273
|
-
if (bytes3 + size2 >
|
|
10377
|
+
if (bytes3 + size2 > maxBytes) {
|
|
10274
10378
|
parts.push(part);
|
|
10275
10379
|
part = "";
|
|
10276
10380
|
bytes3 = 0;
|
|
@@ -13850,6 +13954,10 @@ ALTER TABLE member_agent_sessions ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0;
|
|
|
13850
13954
|
var sessionRewindMigration = `
|
|
13851
13955
|
ALTER TABLE member_session_messages ADD COLUMN superseded_by TEXT;
|
|
13852
13956
|
`;
|
|
13957
|
+
var sessionTranscriptIndexMigration = `
|
|
13958
|
+
CREATE INDEX IF NOT EXISTS member_input_question_answer ON member_agent_inputs(project_id,member_id,json_extract(payload_json,'$.interaction.question'))
|
|
13959
|
+
WHERE json_extract(payload_json,'$.interaction.action')='answer';
|
|
13960
|
+
`;
|
|
13853
13961
|
|
|
13854
13962
|
// apps/server/session-library.ts
|
|
13855
13963
|
var columns = "id,workspace_id,owner,session_key,agent,native_id,cwd,title,revision,updated_at,message_count,hash,size";
|
|
@@ -14257,6 +14365,14 @@ var controlMigration = String.raw`
|
|
|
14257
14365
|
var deviceMigration = String.raw`
|
|
14258
14366
|
CREATE TABLE device_enrollments(workspace_id TEXT NOT NULL, member_id TEXT NOT NULL, operation_id TEXT NOT NULL, fingerprint TEXT NOT NULL, PRIMARY KEY(workspace_id,member_id,operation_id));
|
|
14259
14367
|
`;
|
|
14368
|
+
var clientUpdateMigration = `
|
|
14369
|
+
CREATE TABLE IF NOT EXISTS client_update_devices(
|
|
14370
|
+
workspace_id TEXT NOT NULL, member_id TEXT NOT NULL, device_id TEXT NOT NULL, installation TEXT NOT NULL, status_json TEXT NOT NULL,
|
|
14371
|
+
PRIMARY KEY(workspace_id,member_id,device_id),
|
|
14372
|
+
FOREIGN KEY(workspace_id,member_id,device_id) REFERENCES member_devices(workspace_id,member_id,device_id) ON DELETE CASCADE);
|
|
14373
|
+
CREATE TABLE IF NOT EXISTS client_update_preferences(member_id TEXT NOT NULL,installation TEXT NOT NULL,enabled INTEGER NOT NULL,
|
|
14374
|
+
PRIMARY KEY(member_id,installation));
|
|
14375
|
+
`;
|
|
14260
14376
|
var multiDeviceMigration = `
|
|
14261
14377
|
CREATE TABLE member_devices (
|
|
14262
14378
|
workspace_id TEXT NOT NULL, member_id TEXT NOT NULL, device_id TEXT NOT NULL,
|
|
@@ -18748,7 +18864,9 @@ var migrations = [
|
|
|
18748
18864
|
multiDeviceMigration,
|
|
18749
18865
|
batchInputReceiptsMigration,
|
|
18750
18866
|
computerCompletionMigration,
|
|
18751
|
-
taskCardNumbersMigration
|
|
18867
|
+
taskCardNumbersMigration,
|
|
18868
|
+
sessionTranscriptIndexMigration,
|
|
18869
|
+
clientUpdateMigration
|
|
18752
18870
|
];
|
|
18753
18871
|
var HubStore = class {
|
|
18754
18872
|
constructor(directory) {
|
|
@@ -23899,6 +24017,19 @@ import { ZodError } from "zod";
|
|
|
23899
24017
|
|
|
23900
24018
|
// packages/protocol/devices.ts
|
|
23901
24019
|
import { z as z75 } from "zod";
|
|
24020
|
+
|
|
24021
|
+
// packages/protocol/release-version.ts
|
|
24022
|
+
var stableVersion = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
24023
|
+
function compareVersions(left, right) {
|
|
24024
|
+
const a = left.split(".").map(BigInt), b = right.split(".").map(BigInt);
|
|
24025
|
+
for (let i = 0; i < 3; i++) {
|
|
24026
|
+
if (a[i] < b[i]) return -1;
|
|
24027
|
+
if (a[i] > b[i]) return 1;
|
|
24028
|
+
}
|
|
24029
|
+
return 0;
|
|
24030
|
+
}
|
|
24031
|
+
|
|
24032
|
+
// packages/protocol/devices.ts
|
|
23902
24033
|
var CredentialSchema = z75.string().regex(/^tmy_[a-f0-9]{64}$/);
|
|
23903
24034
|
var EnrollmentSchema = z75.object({
|
|
23904
24035
|
operationId: z75.uuid(),
|
|
@@ -23930,6 +24061,17 @@ var DeviceStatusSchema = z75.object({
|
|
|
23930
24061
|
reportError: z75.string().max(2e3).nullable(),
|
|
23931
24062
|
lastSync: SyncSummarySchema.nullable()
|
|
23932
24063
|
}).strict();
|
|
24064
|
+
var release = z75.string().max(64).regex(stableVersion);
|
|
24065
|
+
var ClientUpdateStatusSchema = z75.object({
|
|
24066
|
+
running: z75.string().min(1).max(64),
|
|
24067
|
+
waiting: release.optional(),
|
|
24068
|
+
issue: z75.string().max(1500).optional()
|
|
24069
|
+
});
|
|
24070
|
+
var ClientUpdateReportSchema = ClientUpdateStatusSchema.extend({ installation: z75.uuid() });
|
|
24071
|
+
var ClientUpdatePolicySchema = z75.object({
|
|
24072
|
+
enabled: z75.boolean(),
|
|
24073
|
+
target: release.nullable()
|
|
24074
|
+
});
|
|
23933
24075
|
var WebDevicesSchema = z75.object({
|
|
23934
24076
|
devices: z75.array(
|
|
23935
24077
|
z75.object({
|
|
@@ -23938,13 +24080,46 @@ var WebDevicesSchema = z75.object({
|
|
|
23938
24080
|
name: z75.string().nullish(),
|
|
23939
24081
|
bound: z75.boolean(),
|
|
23940
24082
|
lastSeenAt: z75.string().nullable(),
|
|
23941
|
-
status: DeviceStatusSchema.nullable()
|
|
24083
|
+
status: DeviceStatusSchema.nullable(),
|
|
24084
|
+
autoUpdate: ClientUpdateStatusSchema.extend({ enabled: z75.boolean() }).optional()
|
|
23942
24085
|
})
|
|
23943
24086
|
)
|
|
23944
24087
|
});
|
|
23945
24088
|
|
|
23946
24089
|
// apps/server/control-routes.ts
|
|
23947
|
-
|
|
24090
|
+
import { z as z76 } from "zod";
|
|
24091
|
+
function registerControlRoutes(server, store, target2) {
|
|
24092
|
+
server.put("/devices/self/client-update", async (request) => {
|
|
24093
|
+
const { workspaceId, memberId, deviceId } = authorizeDevice(store, request);
|
|
24094
|
+
const { installation, ...status } = ClientUpdateReportSchema.parse(request.body);
|
|
24095
|
+
store.db.prepare(
|
|
24096
|
+
`INSERT INTO client_update_devices VALUES(?,?,?,?,?) ON CONFLICT(workspace_id,member_id,device_id)
|
|
24097
|
+
DO UPDATE SET installation=excluded.installation,status_json=excluded.status_json
|
|
24098
|
+
WHERE installation<>excluded.installation OR status_json<>excluded.status_json`
|
|
24099
|
+
).run(workspaceId, memberId, deviceId, installation, JSON.stringify(status));
|
|
24100
|
+
const preference = store.db.prepare(
|
|
24101
|
+
"SELECT enabled FROM client_update_preferences WHERE member_id=? AND installation=?"
|
|
24102
|
+
);
|
|
24103
|
+
const isEnabled = () => preference.get(memberId, installation)?.enabled !== 0;
|
|
24104
|
+
if (!isEnabled()) return { enabled: false, target: null };
|
|
24105
|
+
const release2 = await target2(status.running);
|
|
24106
|
+
const enabled = isEnabled();
|
|
24107
|
+
return { enabled, target: enabled ? release2 : null };
|
|
24108
|
+
});
|
|
24109
|
+
server.put("/web/devices/:device/client-update", async (request) => {
|
|
24110
|
+
webMutation(request);
|
|
24111
|
+
const { workspaceId, memberId } = authorizeWeb(store, request);
|
|
24112
|
+
const { device } = z76.object({ device: z76.uuid() }).parse(request.params);
|
|
24113
|
+
const { enabled } = z76.object({ enabled: z76.boolean() }).parse(request.body);
|
|
24114
|
+
const result = store.db.prepare(
|
|
24115
|
+
`INSERT INTO client_update_preferences(member_id,installation,enabled)
|
|
24116
|
+
SELECT member_id,installation,? FROM client_update_devices WHERE workspace_id=? AND member_id=? AND device_id=?
|
|
24117
|
+
ON CONFLICT(member_id,installation) DO UPDATE SET enabled=excluded.enabled`
|
|
24118
|
+
).run(Number(enabled), workspaceId, memberId, device);
|
|
24119
|
+
if (!result.changes)
|
|
24120
|
+
throw new HubError(404, "DEVICE_NOT_FOUND", "\u627E\u4E0D\u5230\u652F\u6301\u81EA\u52A8\u66F4\u65B0\u7684\u672C\u673A\u8FDE\u63A5\u3002");
|
|
24121
|
+
return { ok: true };
|
|
24122
|
+
});
|
|
23948
24123
|
server.put("/devices/self/status", async (request) => {
|
|
23949
24124
|
const identity = authorizeDevice(store, request);
|
|
23950
24125
|
new ProjectRepository(store).config(identity);
|
|
@@ -23963,16 +24138,25 @@ function registerControlRoutes(server, store) {
|
|
|
23963
24138
|
server.get("/web/devices", async (request) => {
|
|
23964
24139
|
const identity = authorizeWeb(store, request);
|
|
23965
24140
|
const devices = store.db.prepare(
|
|
23966
|
-
`SELECT m.member_id,b.device_id,COALESCE(json_extract(r.config_json,'$.computer.name'),NULLIF(b.label,''),b.device_id) name,d.seen_at,d.status_json
|
|
24141
|
+
`SELECT m.member_id,b.device_id,COALESCE(json_extract(r.config_json,'$.computer.name'),NULLIF(b.label,''),b.device_id) name,d.seen_at,d.status_json,
|
|
24142
|
+
u.status_json update_status,p.enabled update_enabled
|
|
23967
24143
|
FROM members m LEFT JOIN member_devices b USING(workspace_id,member_id)
|
|
23968
24144
|
LEFT JOIN device_status d ON d.workspace_id=b.workspace_id AND d.member_id=b.member_id AND d.device_id=b.device_id
|
|
23969
24145
|
LEFT JOIN member_agent_runtimes r ON r.project_id=m.workspace_id AND r.member_id=m.member_id AND r.device_id=b.device_id
|
|
24146
|
+
LEFT JOIN client_update_devices u ON u.workspace_id=b.workspace_id AND u.member_id=b.member_id AND u.device_id=b.device_id AND u.member_id=?
|
|
24147
|
+
LEFT JOIN client_update_preferences p ON p.member_id=u.member_id AND p.installation=u.installation
|
|
23970
24148
|
WHERE m.workspace_id=? ORDER BY m.member_id,name,b.device_id`
|
|
23971
|
-
).all(identity.workspaceId).map((row) => ({
|
|
24149
|
+
).all(identity.memberId, identity.workspaceId).map((row) => ({
|
|
23972
24150
|
memberId: String(row.member_id),
|
|
23973
24151
|
deviceId: row.device_id,
|
|
23974
24152
|
name: row.name,
|
|
23975
24153
|
bound: Boolean(row.device_id),
|
|
24154
|
+
...row.update_status ? {
|
|
24155
|
+
autoUpdate: {
|
|
24156
|
+
...JSON.parse(String(row.update_status)),
|
|
24157
|
+
enabled: row.update_enabled !== 0
|
|
24158
|
+
}
|
|
24159
|
+
} : {},
|
|
23976
24160
|
lastSeenAt: row.seen_at === null ? null : String(row.seen_at),
|
|
23977
24161
|
status: row.status_json ? DeviceStatusSchema.parse(JSON.parse(String(row.status_json))) : null
|
|
23978
24162
|
}));
|
|
@@ -23981,7 +24165,7 @@ function registerControlRoutes(server, store) {
|
|
|
23981
24165
|
}
|
|
23982
24166
|
|
|
23983
24167
|
// apps/server/project-routes.ts
|
|
23984
|
-
import { z as
|
|
24168
|
+
import { z as z77 } from "zod";
|
|
23985
24169
|
|
|
23986
24170
|
// apps/server/project-activity.ts
|
|
23987
24171
|
function projectWork(hub, identity) {
|
|
@@ -24251,7 +24435,7 @@ function registerProjectScopeRoutes(server, store) {
|
|
|
24251
24435
|
);
|
|
24252
24436
|
server.post("/project/onboarding", async (request) => {
|
|
24253
24437
|
webMutation(request);
|
|
24254
|
-
|
|
24438
|
+
z77.object({}).strict().parse(request.body ?? {});
|
|
24255
24439
|
return recordProjectOnboarding(store, authorizeWeb(store, request));
|
|
24256
24440
|
});
|
|
24257
24441
|
server.get(
|
|
@@ -24313,7 +24497,7 @@ function registerProjectScopeRoutes(server, store) {
|
|
|
24313
24497
|
});
|
|
24314
24498
|
server.patch("/web/members/:id", async (request) => {
|
|
24315
24499
|
webMutation(request);
|
|
24316
|
-
const { id } =
|
|
24500
|
+
const { id } = z77.object({ id: NameSchema }).parse(request.params);
|
|
24317
24501
|
return project.updateMember(
|
|
24318
24502
|
authorizeWeb(store, request),
|
|
24319
24503
|
id,
|
|
@@ -24322,23 +24506,23 @@ function registerProjectScopeRoutes(server, store) {
|
|
|
24322
24506
|
});
|
|
24323
24507
|
server.post("/web/members/:id/device-reset", async (request) => {
|
|
24324
24508
|
webMutation(request);
|
|
24325
|
-
const { id } =
|
|
24326
|
-
const { expectedRevision, deviceId } =
|
|
24327
|
-
expectedRevision:
|
|
24328
|
-
deviceId:
|
|
24509
|
+
const { id } = z77.object({ id: NameSchema }).parse(request.params);
|
|
24510
|
+
const { expectedRevision, deviceId } = z77.object({
|
|
24511
|
+
expectedRevision: z77.number().int().nonnegative().optional(),
|
|
24512
|
+
deviceId: z77.uuid().optional()
|
|
24329
24513
|
}).strict().parse(request.body ?? {});
|
|
24330
24514
|
return project.resetDevice(authorizeWeb(store, request), id, expectedRevision, deviceId);
|
|
24331
24515
|
});
|
|
24332
24516
|
}
|
|
24333
24517
|
|
|
24334
24518
|
// apps/server/diagnostics/routes.ts
|
|
24335
|
-
import { z as
|
|
24519
|
+
import { z as z78 } from "zod";
|
|
24336
24520
|
function registerDiagnosticRoutes(server, hub) {
|
|
24337
24521
|
for (const kind2 of ["file", "related"])
|
|
24338
24522
|
server.get(`/diagnostics/:id/${kind2}`, async (req, reply) => {
|
|
24339
24523
|
const identity = authorizeWeb(hub, req);
|
|
24340
24524
|
requireSiteAdmin(identity);
|
|
24341
|
-
const { id } =
|
|
24525
|
+
const { id } = z78.object({ id: z78.uuid() }).parse(req.params);
|
|
24342
24526
|
const logs = new Diagnostics(hub);
|
|
24343
24527
|
const row = logs.get(identity.workspaceId, id);
|
|
24344
24528
|
reply.header("x-content-type-options", "nosniff");
|
|
@@ -24352,7 +24536,7 @@ function registerDiagnosticRoutes(server, hub) {
|
|
|
24352
24536
|
}
|
|
24353
24537
|
|
|
24354
24538
|
// apps/server/site-routes.ts
|
|
24355
|
-
import { z as
|
|
24539
|
+
import { z as z79 } from "zod";
|
|
24356
24540
|
|
|
24357
24541
|
// apps/server/devices.ts
|
|
24358
24542
|
var DeviceRepository = class {
|
|
@@ -24481,7 +24665,7 @@ function registerSiteRoutes(server, store) {
|
|
|
24481
24665
|
"/api/v1/web/session",
|
|
24482
24666
|
{ onRequest: async (request) => webMutation(request) },
|
|
24483
24667
|
async (request, reply) => {
|
|
24484
|
-
const { id } =
|
|
24668
|
+
const { id } = z79.object({ id: NameSchema }).strict().parse(request.body);
|
|
24485
24669
|
if (server.teammyTaiAuth) {
|
|
24486
24670
|
if (id !== server.teammyTaiAuth.identity(request).loginName)
|
|
24487
24671
|
throw new HubError(403, "TAI_IDENTITY_MISMATCH", "\u767B\u5F55 ID \u5FC5\u987B\u4E0E\u5F53\u524D\u516C\u53F8\u8D26\u53F7\u4E00\u81F4\u3002");
|
|
@@ -24494,7 +24678,7 @@ function registerSiteRoutes(server, store) {
|
|
|
24494
24678
|
server.patch("/api/v1/web/session", async (request) => {
|
|
24495
24679
|
webMutation(request);
|
|
24496
24680
|
const identity = site.identity(cookieToken(request));
|
|
24497
|
-
const { displayName } =
|
|
24681
|
+
const { displayName } = z79.object({ displayName: z79.string().trim().max(120) }).strict().parse(request.body);
|
|
24498
24682
|
return site.renameSelf(identity, displayName);
|
|
24499
24683
|
});
|
|
24500
24684
|
server.delete("/api/v1/web/session", async (request, reply) => {
|
|
@@ -24545,7 +24729,7 @@ function registerSiteRoutes(server, store) {
|
|
|
24545
24729
|
}
|
|
24546
24730
|
|
|
24547
24731
|
// apps/server/session-routes.ts
|
|
24548
|
-
import { z as
|
|
24732
|
+
import { z as z80 } from "zod";
|
|
24549
24733
|
function registerSessionRoutes(server, store) {
|
|
24550
24734
|
const sessions2 = new SessionRepository(store);
|
|
24551
24735
|
server.get(
|
|
@@ -24555,7 +24739,7 @@ function registerSessionRoutes(server, store) {
|
|
|
24555
24739
|
server.put("/web/session-library", async (request) => {
|
|
24556
24740
|
webMutation(request);
|
|
24557
24741
|
const identity = authorizeWeb(store, request);
|
|
24558
|
-
const { enabled } =
|
|
24742
|
+
const { enabled } = z80.object({ enabled: z80.boolean() }).strict().parse(request.body);
|
|
24559
24743
|
return setSessionLibraryPreference(store, identity, enabled);
|
|
24560
24744
|
});
|
|
24561
24745
|
const device = (request) => typeof request.headers["x-teammy-device"] === "string" ? request.headers["x-teammy-device"] : void 0;
|
|
@@ -24565,9 +24749,9 @@ function registerSessionRoutes(server, store) {
|
|
|
24565
24749
|
authorize(request);
|
|
24566
24750
|
}
|
|
24567
24751
|
};
|
|
24568
|
-
const pagination =
|
|
24569
|
-
after:
|
|
24570
|
-
limit:
|
|
24752
|
+
const pagination = z80.object({
|
|
24753
|
+
after: z80.coerce.number().pipe(RevisionSchema).default(0),
|
|
24754
|
+
limit: z80.coerce.number().int().min(1).max(100).default(50)
|
|
24571
24755
|
});
|
|
24572
24756
|
server.post(
|
|
24573
24757
|
"/sessions/commits",
|
|
@@ -24581,17 +24765,17 @@ function registerSessionRoutes(server, store) {
|
|
|
24581
24765
|
server.get("/sessions", async (request) => {
|
|
24582
24766
|
const q = pagination.extend({
|
|
24583
24767
|
owner: NameSchema.optional(),
|
|
24584
|
-
order:
|
|
24768
|
+
order: z80.enum(["created", "title", "updated"]).default("created")
|
|
24585
24769
|
}).parse(request.query);
|
|
24586
24770
|
return sessions2.list(authorizeRead(store, request), q.after, q.limit, q.owner, q.order);
|
|
24587
24771
|
});
|
|
24588
24772
|
server.get("/sessions/stats", async (request) => sessions2.stats(authorizeRead(store, request)));
|
|
24589
24773
|
server.get("/sessions/search", async (request) => {
|
|
24590
24774
|
const q = pagination.extend({
|
|
24591
|
-
order:
|
|
24775
|
+
order: z80.enum(["created", "updated"]).default("created"),
|
|
24592
24776
|
owner: NameSchema.optional(),
|
|
24593
24777
|
sessionKey: HashSchema.optional(),
|
|
24594
|
-
q:
|
|
24778
|
+
q: z80.string().min(1).max(500).refine((s) => !s.includes("\0"))
|
|
24595
24779
|
}).parse(request.query);
|
|
24596
24780
|
return sessions2.search(
|
|
24597
24781
|
authorizeRead(store, request),
|
|
@@ -24603,17 +24787,17 @@ function registerSessionRoutes(server, store) {
|
|
|
24603
24787
|
);
|
|
24604
24788
|
});
|
|
24605
24789
|
server.get("/sessions/:owner/:key", async (request) => {
|
|
24606
|
-
const p =
|
|
24607
|
-
const q =
|
|
24790
|
+
const p = z80.object({ owner: NameSchema, key: HashSchema }).parse(request.params);
|
|
24791
|
+
const q = z80.object({ revision: z80.coerce.number().pipe(RevisionSchema).optional() }).parse(request.query);
|
|
24608
24792
|
return sessions2.read(authorizeRead(store, request), p.owner, p.key, q.revision);
|
|
24609
24793
|
});
|
|
24610
24794
|
server.get("/sessions/:owner/:key/baseline", guard, async (request) => {
|
|
24611
|
-
const p =
|
|
24795
|
+
const p = z80.object({ owner: NameSchema, key: HashSchema }).parse(request.params);
|
|
24612
24796
|
return sessions2.baseline(authorize(request), p.owner, p.key);
|
|
24613
24797
|
});
|
|
24614
24798
|
server.get("/sessions/:owner/:key/analysis/:kind", async (request) => {
|
|
24615
|
-
const p =
|
|
24616
|
-
const q =
|
|
24799
|
+
const p = z80.object({ owner: NameSchema, key: HashSchema, kind: SessionAnalysisKindSchema }).parse(request.params);
|
|
24800
|
+
const q = z80.object({ revision: z80.coerce.number().pipe(RevisionSchema).optional() }).parse(request.query);
|
|
24617
24801
|
const identity = authorizeRead(store, request);
|
|
24618
24802
|
return sessionAnalysisState(
|
|
24619
24803
|
store,
|
|
@@ -24625,13 +24809,13 @@ function registerSessionRoutes(server, store) {
|
|
|
24625
24809
|
});
|
|
24626
24810
|
server.post("/sessions/:owner/:key/handoff", async (request) => {
|
|
24627
24811
|
if (!request.headers.authorization) webMutation(request);
|
|
24628
|
-
const p =
|
|
24812
|
+
const p = z80.object({ owner: NameSchema, key: HashSchema }).parse(request.params);
|
|
24629
24813
|
return requestSessionHandoff(store, authorizeRead(store, request), p.owner, p.key);
|
|
24630
24814
|
});
|
|
24631
24815
|
}
|
|
24632
24816
|
|
|
24633
24817
|
// apps/server/file-routes.ts
|
|
24634
|
-
import { z as
|
|
24818
|
+
import { z as z81 } from "zod";
|
|
24635
24819
|
function registerFileRoutes(server, store) {
|
|
24636
24820
|
const files = new FileRepository(store);
|
|
24637
24821
|
const shared = new SharedFilesRepository(store);
|
|
@@ -24670,14 +24854,14 @@ function registerFileRoutes(server, store) {
|
|
|
24670
24854
|
missing: files.missing(authorize(request), BlobCheckSchema.parse(request.body).hashes)
|
|
24671
24855
|
}));
|
|
24672
24856
|
server.put("/blobs/:hash", { ...guard, bodyLimit: MAX_BLOB_BYTES }, async (request) => {
|
|
24673
|
-
const { hash: hash3 } =
|
|
24857
|
+
const { hash: hash3 } = z81.object({ hash: HashSchema }).parse(request.params);
|
|
24674
24858
|
if (!Buffer.isBuffer(request.body))
|
|
24675
24859
|
throw Object.assign(new Error("Expected binary content"), { statusCode: 400 });
|
|
24676
24860
|
return files.upload(request.headers.authorization, device(request), hash3, request.body);
|
|
24677
24861
|
});
|
|
24678
24862
|
server.get("/blobs/:hash", async (request, reply) => {
|
|
24679
|
-
const { hash: hash3 } =
|
|
24680
|
-
const { view } =
|
|
24863
|
+
const { hash: hash3 } = z81.object({ hash: HashSchema }).parse(request.params);
|
|
24864
|
+
const { view } = z81.object({ view: z81.literal("html").optional() }).parse(request.query);
|
|
24681
24865
|
const bytes3 = await files.download(authorizeRead(store, request), hash3);
|
|
24682
24866
|
if (view === "html") return sendHtmlPreview(reply, bytes3);
|
|
24683
24867
|
return reply.type("application/octet-stream").send(Buffer.from(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength));
|
|
@@ -24720,7 +24904,7 @@ function registerFileRoutes(server, store) {
|
|
|
24720
24904
|
});
|
|
24721
24905
|
server.get("/files/self/operations/:operation", guard, async (request) => {
|
|
24722
24906
|
const actor = authorize(request);
|
|
24723
|
-
const { operation } =
|
|
24907
|
+
const { operation } = z81.object({ operation: z81.uuid() }).parse(request.params);
|
|
24724
24908
|
const row = store.db.prepare(
|
|
24725
24909
|
"SELECT revision FROM file_operations WHERE workspace_id=? AND owner=? AND operation_id=?"
|
|
24726
24910
|
).get(actor.workspaceId, actor.memberId, operation);
|
|
@@ -24728,7 +24912,7 @@ function registerFileRoutes(server, store) {
|
|
|
24728
24912
|
});
|
|
24729
24913
|
server.get("/files/_project/operations/:operation", guard, async (request) => {
|
|
24730
24914
|
const actor = authorize(request);
|
|
24731
|
-
const { operation } =
|
|
24915
|
+
const { operation } = z81.object({ operation: z81.uuid() }).parse(request.params);
|
|
24732
24916
|
const row = store.db.prepare(
|
|
24733
24917
|
"SELECT revision FROM file_operations WHERE workspace_id=? AND owner=? AND operation_id=?"
|
|
24734
24918
|
).get(actor.workspaceId, "_project", operation);
|
|
@@ -24736,7 +24920,7 @@ function registerFileRoutes(server, store) {
|
|
|
24736
24920
|
});
|
|
24737
24921
|
server.get("/files/:owner/operations/:operation", guard, async (request) => {
|
|
24738
24922
|
const actor = authorize(request);
|
|
24739
|
-
const { owner, operation } =
|
|
24923
|
+
const { owner, operation } = z81.object({ owner: FileOwnerSchema, operation: z81.uuid() }).parse(request.params);
|
|
24740
24924
|
const row = store.db.prepare(
|
|
24741
24925
|
"SELECT revision FROM file_operations WHERE workspace_id=? AND owner=? AND operation_id=?"
|
|
24742
24926
|
).get(actor.workspaceId, owner, operation);
|
|
@@ -24747,11 +24931,11 @@ function registerFileRoutes(server, store) {
|
|
|
24747
24931
|
return new TaskFiles(store).resolveName(authorize(request), input.path, input.expectedHash);
|
|
24748
24932
|
});
|
|
24749
24933
|
server.get("/files/:owner/manifest", async (request) => {
|
|
24750
|
-
const { owner } =
|
|
24751
|
-
const query2 =
|
|
24752
|
-
revision:
|
|
24753
|
-
after:
|
|
24754
|
-
limit:
|
|
24934
|
+
const { owner } = z81.object({ owner: FileOwnerSchema }).parse(request.params);
|
|
24935
|
+
const query2 = z81.object({
|
|
24936
|
+
revision: z81.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
24937
|
+
after: z81.string().max(1024).default(""),
|
|
24938
|
+
limit: z81.coerce.number().int().min(1).max(500).default(200)
|
|
24755
24939
|
}).parse(request.query);
|
|
24756
24940
|
return files.manifest(
|
|
24757
24941
|
await fileIdentity(request, owner),
|
|
@@ -24762,20 +24946,20 @@ function registerFileRoutes(server, store) {
|
|
|
24762
24946
|
);
|
|
24763
24947
|
});
|
|
24764
24948
|
server.get("/files/:owner/entry", async (request) => {
|
|
24765
|
-
const { owner } =
|
|
24766
|
-
const q =
|
|
24949
|
+
const { owner } = z81.object({ owner: FileOwnerSchema }).parse(request.params);
|
|
24950
|
+
const q = z81.object({
|
|
24767
24951
|
path: FilePathSchema,
|
|
24768
|
-
revision:
|
|
24952
|
+
revision: z81.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional()
|
|
24769
24953
|
}).parse(request.query);
|
|
24770
24954
|
return files.entry(await fileIdentity(request, owner), owner, q.path, q.revision);
|
|
24771
24955
|
});
|
|
24772
24956
|
server.get("/files/:owner/tree", async (request) => {
|
|
24773
|
-
const { owner } =
|
|
24774
|
-
const q =
|
|
24775
|
-
path:
|
|
24776
|
-
revision:
|
|
24777
|
-
after:
|
|
24778
|
-
limit:
|
|
24957
|
+
const { owner } = z81.object({ owner: FileOwnerSchema }).parse(request.params);
|
|
24958
|
+
const q = z81.object({
|
|
24959
|
+
path: z81.union([z81.literal(""), FilePathSchema]).default(""),
|
|
24960
|
+
revision: z81.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
24961
|
+
after: z81.string().max(255).default(""),
|
|
24962
|
+
limit: z81.coerce.number().int().min(1).max(200).default(100)
|
|
24779
24963
|
}).parse(request.query);
|
|
24780
24964
|
return files.tree(
|
|
24781
24965
|
await fileIdentity(request, owner),
|
|
@@ -24787,10 +24971,10 @@ function registerFileRoutes(server, store) {
|
|
|
24787
24971
|
);
|
|
24788
24972
|
});
|
|
24789
24973
|
server.get("/files/:owner/changes", async (request) => {
|
|
24790
|
-
const { owner } =
|
|
24791
|
-
const query2 =
|
|
24792
|
-
after:
|
|
24793
|
-
limit:
|
|
24974
|
+
const { owner } = z81.object({ owner: FileOwnerSchema }).parse(request.params);
|
|
24975
|
+
const query2 = z81.object({
|
|
24976
|
+
after: z81.coerce.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),
|
|
24977
|
+
limit: z81.coerce.number().int().min(1).max(100).default(100)
|
|
24794
24978
|
}).parse(request.query);
|
|
24795
24979
|
return files.changes(await fileIdentity(request, owner), owner, query2.after, query2.limit);
|
|
24796
24980
|
});
|
|
@@ -24833,7 +25017,7 @@ function clearUnread(hub, identity, scope2) {
|
|
|
24833
25017
|
|
|
24834
25018
|
// apps/server/agents/routes.ts
|
|
24835
25019
|
import { createHash as createHash29 } from "node:crypto";
|
|
24836
|
-
import { z as
|
|
25020
|
+
import { z as z82 } from "zod";
|
|
24837
25021
|
|
|
24838
25022
|
// apps/server/agents/ssh-key.ts
|
|
24839
25023
|
import { execFile as execFile2 } from "node:child_process";
|
|
@@ -24892,7 +25076,7 @@ function registerProjectAgentRoutes(server, hub) {
|
|
|
24892
25076
|
webMutation(req);
|
|
24893
25077
|
return topics.publish(authorizeWeb(hub, req), messageId(req.params));
|
|
24894
25078
|
});
|
|
24895
|
-
const messageId = (value) =>
|
|
25079
|
+
const messageId = (value) => z82.object({ id: z82.uuid() }).parse(value).id;
|
|
24896
25080
|
server.addHook("preClose", async () => {
|
|
24897
25081
|
for (const stream of streams) stream.end();
|
|
24898
25082
|
});
|
|
@@ -25054,7 +25238,7 @@ data: ${event.data}
|
|
|
25054
25238
|
server.post("/agents/chats/:id/read", async (req) => {
|
|
25055
25239
|
webMutation(req);
|
|
25056
25240
|
const identity = authorizeWeb(hub, req);
|
|
25057
|
-
const { cursor } =
|
|
25241
|
+
const { cursor } = z82.object({ cursor: z82.number().int().nonnegative() }).strict().parse(req.body);
|
|
25058
25242
|
const id = messageId(req.params);
|
|
25059
25243
|
markChatRead(hub, identity, id, cursor);
|
|
25060
25244
|
return { ok: true };
|
|
@@ -25062,7 +25246,7 @@ data: ${event.data}
|
|
|
25062
25246
|
server.get("/agents/outbox", async (req) => store.messages(authorizeWeb(hub, req)));
|
|
25063
25247
|
server.post("/communication/read", async (req) => {
|
|
25064
25248
|
webMutation(req);
|
|
25065
|
-
const { scope: scope2 } =
|
|
25249
|
+
const { scope: scope2 } = z82.object({ scope: z82.enum(["messages", "channels"]) }).strict().parse(req.body);
|
|
25066
25250
|
return clearUnread(hub, authorizeWeb(hub, req), scope2);
|
|
25067
25251
|
});
|
|
25068
25252
|
server.get("/communication/unread", async (req) => {
|
|
@@ -25191,39 +25375,39 @@ function registerBootstrapRoutes(server, hub) {
|
|
|
25191
25375
|
}
|
|
25192
25376
|
|
|
25193
25377
|
// apps/server/client-access.ts
|
|
25194
|
-
import { z as
|
|
25378
|
+
import { z as z84 } from "zod";
|
|
25195
25379
|
|
|
25196
25380
|
// packages/protocol/client-access.ts
|
|
25197
|
-
import { z as
|
|
25198
|
-
var ConnectSecretSchema =
|
|
25199
|
-
var BrowserConnectRequestSchema =
|
|
25200
|
-
id:
|
|
25381
|
+
import { z as z83 } from "zod";
|
|
25382
|
+
var ConnectSecretSchema = z83.string().regex(/^[a-f0-9]{64}$/);
|
|
25383
|
+
var BrowserConnectRequestSchema = z83.object({
|
|
25384
|
+
id: z83.uuid(),
|
|
25201
25385
|
projectId: NameSchema,
|
|
25202
25386
|
deviceId: DeviceIdSchema,
|
|
25203
25387
|
secret: ConnectSecretSchema,
|
|
25204
|
-
label:
|
|
25388
|
+
label: z83.string().min(1).max(255)
|
|
25205
25389
|
}).strict();
|
|
25206
|
-
var BrowserConnectStartSchema =
|
|
25207
|
-
id:
|
|
25208
|
-
expiresAt:
|
|
25209
|
-
verificationUrl:
|
|
25390
|
+
var BrowserConnectStartSchema = z83.object({
|
|
25391
|
+
id: z83.uuid(),
|
|
25392
|
+
expiresAt: z83.number(),
|
|
25393
|
+
verificationUrl: z83.string().url().optional()
|
|
25210
25394
|
});
|
|
25211
|
-
var BrowserConnectPollSchema =
|
|
25212
|
-
|
|
25213
|
-
|
|
25395
|
+
var BrowserConnectPollSchema = z83.discriminatedUnion("state", [
|
|
25396
|
+
z83.object({ state: z83.literal("pending") }),
|
|
25397
|
+
z83.object({ state: z83.literal("approved"), memberId: NameSchema })
|
|
25214
25398
|
]);
|
|
25215
|
-
var BrowserConnectInfoSchema =
|
|
25216
|
-
projectName:
|
|
25217
|
-
label:
|
|
25399
|
+
var BrowserConnectInfoSchema = z83.object({
|
|
25400
|
+
projectName: z83.string(),
|
|
25401
|
+
label: z83.string(),
|
|
25218
25402
|
approvedBy: NameSchema.nullable(),
|
|
25219
|
-
expiresAt:
|
|
25403
|
+
expiresAt: z83.number()
|
|
25220
25404
|
});
|
|
25221
25405
|
|
|
25222
25406
|
// apps/server/client-access.ts
|
|
25223
25407
|
function registerClientAccess(server, store) {
|
|
25224
25408
|
const project = new ProjectRepository(store);
|
|
25225
25409
|
const read = (id) => {
|
|
25226
|
-
const row = store.db.prepare("SELECT * FROM device_connect_requests WHERE id=?").get(
|
|
25410
|
+
const row = store.db.prepare("SELECT * FROM device_connect_requests WHERE id=?").get(z84.uuid().parse(id));
|
|
25227
25411
|
if (!row || Number(row.expires_at) <= Date.now())
|
|
25228
25412
|
throw new HubError(410, "CONNECT_EXPIRED", "\u8FDE\u63A5\u8BF7\u6C42\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C teammy connect\u3002");
|
|
25229
25413
|
return row;
|
|
@@ -25258,7 +25442,7 @@ function registerClientAccess(server, store) {
|
|
|
25258
25442
|
};
|
|
25259
25443
|
});
|
|
25260
25444
|
server.post("/api/v1/devices/connect/:id/poll", async (request) => {
|
|
25261
|
-
const { secret } =
|
|
25445
|
+
const { secret } = z84.object({ secret: ConnectSecretSchema }).strict().parse(request.body);
|
|
25262
25446
|
const row = read(request.params.id);
|
|
25263
25447
|
if (row.secret_hash !== digest(secret))
|
|
25264
25448
|
throw new HubError(
|
|
@@ -25302,19 +25486,21 @@ function registerClientAccess(server, store) {
|
|
|
25302
25486
|
}
|
|
25303
25487
|
|
|
25304
25488
|
// apps/server/client-release.ts
|
|
25305
|
-
import { z as
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
|
|
25489
|
+
import { z as z85 } from "zod";
|
|
25490
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
25491
|
+
import { join as join30 } from "node:path";
|
|
25492
|
+
var ReleaseSchema = z85.object({
|
|
25493
|
+
name: z85.literal("@teammy/cli"),
|
|
25494
|
+
"dist-tags": z85.object({
|
|
25495
|
+
latest: z85.string().regex(/^\d+\.\d+\.\d+(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/i)
|
|
25310
25496
|
}),
|
|
25311
|
-
versions:
|
|
25497
|
+
versions: z85.record(z85.string(), z85.unknown())
|
|
25312
25498
|
});
|
|
25313
|
-
function registerClientRelease(server) {
|
|
25499
|
+
function registerClientRelease(server, version2, dataDir) {
|
|
25314
25500
|
let cached;
|
|
25315
25501
|
let expiresAt = 0;
|
|
25316
25502
|
let pending;
|
|
25317
|
-
|
|
25503
|
+
async function latest() {
|
|
25318
25504
|
if (Date.now() >= expiresAt) {
|
|
25319
25505
|
pending ??= (async () => {
|
|
25320
25506
|
try {
|
|
@@ -25323,10 +25509,10 @@ function registerClientRelease(server) {
|
|
|
25323
25509
|
signal: AbortSignal.timeout(5e3)
|
|
25324
25510
|
});
|
|
25325
25511
|
if (!response.ok) throw new Error("Registry unavailable.");
|
|
25326
|
-
const
|
|
25327
|
-
const
|
|
25328
|
-
if (!Object.hasOwn(
|
|
25329
|
-
cached = { version:
|
|
25512
|
+
const release2 = ReleaseSchema.parse(await response.json());
|
|
25513
|
+
const version3 = release2["dist-tags"].latest;
|
|
25514
|
+
if (!Object.hasOwn(release2.versions, version3)) throw new Error("Latest release missing.");
|
|
25515
|
+
cached = { version: version3, versions: Object.keys(release2.versions) };
|
|
25330
25516
|
expiresAt = Date.now() + 5 * 6e4;
|
|
25331
25517
|
} catch {
|
|
25332
25518
|
cached = void 0;
|
|
@@ -25340,11 +25526,25 @@ function registerClientRelease(server) {
|
|
|
25340
25526
|
if (!cached)
|
|
25341
25527
|
throw new HubError(503, "CLIENT_RELEASE_UNAVAILABLE", "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u6700\u65B0\u7248\u5BA2\u6237\u7AEF\u7248\u672C\u3002");
|
|
25342
25528
|
return cached;
|
|
25343
|
-
}
|
|
25529
|
+
}
|
|
25530
|
+
server.get("/api/v1/client/latest", latest);
|
|
25531
|
+
return async (running) => {
|
|
25532
|
+
let target2 = true ? "0.2.19" : version2;
|
|
25533
|
+
if (dataDir) {
|
|
25534
|
+
try {
|
|
25535
|
+
target2 = (await readFile8(join30(dataDir, "client-update-version"), "utf8")).trim();
|
|
25536
|
+
} catch (error) {
|
|
25537
|
+
if (error.code !== "ENOENT") throw error;
|
|
25538
|
+
}
|
|
25539
|
+
}
|
|
25540
|
+
if (!stableVersion.test(target2) || !stableVersion.test(running) || compareVersions(target2, running) <= 0)
|
|
25541
|
+
return null;
|
|
25542
|
+
return (await latest()).versions.includes(target2) ? target2 : null;
|
|
25543
|
+
};
|
|
25344
25544
|
}
|
|
25345
25545
|
|
|
25346
25546
|
// apps/server/wecom/routes.ts
|
|
25347
|
-
import { z as
|
|
25547
|
+
import { z as z86 } from "zod";
|
|
25348
25548
|
|
|
25349
25549
|
// apps/server/wecom/runtime.ts
|
|
25350
25550
|
import { randomUUID as randomUUID40 } from "node:crypto";
|
|
@@ -26141,6 +26341,20 @@ var WecomRuntime = class {
|
|
|
26141
26341
|
const channel = delivery.chat_type === 3 ? JSON.parse(delivery.channel_json) : null;
|
|
26142
26342
|
const target2 = channel ? `channel:${delivery.external_id}:${channel.conversationId}` : `${delivery.chat_type ?? 1}:${delivery.external_id}`;
|
|
26143
26343
|
if (targets.has(target2)) continue;
|
|
26344
|
+
const part = delivery.kind === computerCompletionCategory && /:(\d+)$/.exec(delivery.source_id);
|
|
26345
|
+
if (part) {
|
|
26346
|
+
const base = delivery.source_id.slice(0, part.index);
|
|
26347
|
+
const previous = Number(part[1]) - 1;
|
|
26348
|
+
if (!this.hub.db.prepare(
|
|
26349
|
+
"SELECT 1 FROM wecom_deliveries WHERE bot_id=? AND external_id=? AND kind=? AND source_id=? AND state='sent'"
|
|
26350
|
+
).get(
|
|
26351
|
+
delivery.bot_id,
|
|
26352
|
+
delivery.external_id,
|
|
26353
|
+
delivery.kind,
|
|
26354
|
+
previous ? `${base}:${previous}` : base
|
|
26355
|
+
))
|
|
26356
|
+
continue;
|
|
26357
|
+
}
|
|
26144
26358
|
if (channel?.action === "post" && this.hub.db.prepare(
|
|
26145
26359
|
`SELECT 1 FROM wecom_deliveries WHERE bot_id=? AND external_id=? AND chat_type=3 AND state='pending' AND json_extract(channel_json,'$.action')='post' AND rowid<(SELECT rowid FROM wecom_deliveries WHERE id=?)`
|
|
26146
26360
|
).get(delivery.bot_id, delivery.external_id, delivery.id))
|
|
@@ -26225,7 +26439,7 @@ function registerWecom(server, hub, env, factory) {
|
|
|
26225
26439
|
webMutation(req);
|
|
26226
26440
|
return channels2.bind(
|
|
26227
26441
|
authorizeWeb(hub, req),
|
|
26228
|
-
|
|
26442
|
+
z86.object({ topicId: z86.string().min(1).nullable() }).strict().parse(req.body).topicId
|
|
26229
26443
|
);
|
|
26230
26444
|
});
|
|
26231
26445
|
server.get(`${base}/groups`, async (req) => groups.list(authorizeWeb(hub, req)));
|
|
@@ -26237,7 +26451,7 @@ function registerWecom(server, hub, env, factory) {
|
|
|
26237
26451
|
webMutation(req);
|
|
26238
26452
|
return groups.remove(
|
|
26239
26453
|
authorizeWeb(hub, req),
|
|
26240
|
-
|
|
26454
|
+
z86.object({ chatId: z86.string().min(1) }).parse(req.params).chatId
|
|
26241
26455
|
);
|
|
26242
26456
|
});
|
|
26243
26457
|
server.get(base, async (req) => store.binding(authorizeWeb(hub, req)));
|
|
@@ -26379,20 +26593,20 @@ function registerTaiAuth(server, store, env) {
|
|
|
26379
26593
|
}
|
|
26380
26594
|
|
|
26381
26595
|
// packages/protocol/deployment-migration.ts
|
|
26382
|
-
import { z as
|
|
26596
|
+
import { z as z87 } from "zod";
|
|
26383
26597
|
var ANYDEV_MIGRATION = {
|
|
26384
26598
|
id: "anydev-20261112",
|
|
26385
26599
|
from: "https://ms-cm2lcn7d-100034032793-sw.gw.ap-zhongwei.ti.tencentcs.com/ms-cm2lcn7d",
|
|
26386
26600
|
previous: "https://teammy.woa.com/client",
|
|
26387
26601
|
to: "http://teammy.woa.com/client"
|
|
26388
26602
|
};
|
|
26389
|
-
var DeploymentMigrationSchema =
|
|
26390
|
-
migration:
|
|
26603
|
+
var DeploymentMigrationSchema = z87.object({
|
|
26604
|
+
migration: z87.string(),
|
|
26391
26605
|
binding: BindingSchema
|
|
26392
26606
|
});
|
|
26393
26607
|
|
|
26394
26608
|
// apps/server/messaging/routes.ts
|
|
26395
|
-
import { z as
|
|
26609
|
+
import { z as z88 } from "zod";
|
|
26396
26610
|
function registerEventRouting(server, hub) {
|
|
26397
26611
|
const routing = new EventRouting(hub);
|
|
26398
26612
|
server.get("/web/event-routing", async (req) => routing.settings(authorizeWeb(hub, req)));
|
|
@@ -26438,7 +26652,7 @@ function registerEventRouting(server, hub) {
|
|
|
26438
26652
|
webMutation(req);
|
|
26439
26653
|
return routing.reassign(
|
|
26440
26654
|
authorizeWeb(hub, req),
|
|
26441
|
-
|
|
26655
|
+
z88.object({ id: z88.uuid() }).parse(req.params).id,
|
|
26442
26656
|
req.body
|
|
26443
26657
|
);
|
|
26444
26658
|
});
|
|
@@ -26450,20 +26664,20 @@ function registerEventRouting(server, hub) {
|
|
|
26450
26664
|
"/event-hooks/:id",
|
|
26451
26665
|
async (req) => routing.setHook(
|
|
26452
26666
|
authorizeDevice(hub, req),
|
|
26453
|
-
|
|
26454
|
-
|
|
26667
|
+
z88.object({ id: z88.uuid() }).parse(req.params).id,
|
|
26668
|
+
z88.object({ enabled: z88.boolean() }).strict().parse(req.body).enabled
|
|
26455
26669
|
)
|
|
26456
26670
|
);
|
|
26457
26671
|
server.patch("/web/event-hooks/:id", async (req) => {
|
|
26458
26672
|
webMutation(req);
|
|
26459
26673
|
return routing.setHook(
|
|
26460
26674
|
authorizeWeb(hub, req),
|
|
26461
|
-
|
|
26462
|
-
|
|
26675
|
+
z88.object({ id: z88.uuid() }).parse(req.params).id,
|
|
26676
|
+
z88.object({ enabled: z88.boolean() }).strict().parse(req.body).enabled
|
|
26463
26677
|
);
|
|
26464
26678
|
});
|
|
26465
26679
|
server.get("/web/channel-topics/:id/subscription", async (req) => {
|
|
26466
|
-
const identity = authorizeWeb(hub, req), { id } =
|
|
26680
|
+
const identity = authorizeWeb(hub, req), { id } = z88.object({ id: z88.uuid() }).parse(req.params);
|
|
26467
26681
|
new AgentStore(hub).ownedChat(identity, id);
|
|
26468
26682
|
if (!new WebChannels(hub).isTopic(identity.workspaceId, id))
|
|
26469
26683
|
throw new HubError(404, "TOPIC_NOT_FOUND", "\u8BDD\u9898\u4E0D\u5B58\u5728\u3002");
|
|
@@ -26475,11 +26689,11 @@ function registerEventRouting(server, hub) {
|
|
|
26475
26689
|
});
|
|
26476
26690
|
server.put("/web/channel-topics/:id/subscription", async (req) => {
|
|
26477
26691
|
webMutation(req);
|
|
26478
|
-
const identity = authorizeWeb(hub, req), { id } =
|
|
26692
|
+
const identity = authorizeWeb(hub, req), { id } = z88.object({ id: z88.uuid() }).parse(req.params);
|
|
26479
26693
|
new AgentStore(hub).ownedChat(identity, id);
|
|
26480
26694
|
if (!new WebChannels(hub).isTopic(identity.workspaceId, id))
|
|
26481
26695
|
throw new HubError(404, "TOPIC_NOT_FOUND", "\u8BDD\u9898\u4E0D\u5B58\u5728\u3002");
|
|
26482
|
-
const { subscribed } =
|
|
26696
|
+
const { subscribed } = z88.object({ subscribed: z88.boolean() }).strict().parse(req.body);
|
|
26483
26697
|
if (subscribed)
|
|
26484
26698
|
hub.db.prepare("INSERT OR IGNORE INTO routing_topic_subscriptions VALUES(?,?,?)").run(identity.workspaceId, identity.memberId, id);
|
|
26485
26699
|
else
|
|
@@ -26489,7 +26703,7 @@ function registerEventRouting(server, hub) {
|
|
|
26489
26703
|
return { subscribed };
|
|
26490
26704
|
});
|
|
26491
26705
|
server.get("/web/local-agent-sessions/:id/group-sync", async (req) => {
|
|
26492
|
-
const identity = authorizeWeb(hub, req), { id } =
|
|
26706
|
+
const identity = authorizeWeb(hub, req), { id } = z88.object({ id: ExecutionRef }).parse(req.params);
|
|
26493
26707
|
new MemberSessions(hub).get(identity, id);
|
|
26494
26708
|
return {
|
|
26495
26709
|
enabled: !!hub.db.prepare("SELECT group_sync FROM member_agent_sessions WHERE project_id=? AND id=?").get(identity.workspaceId, id)?.group_sync
|
|
@@ -26497,9 +26711,9 @@ function registerEventRouting(server, hub) {
|
|
|
26497
26711
|
});
|
|
26498
26712
|
server.put("/web/local-agent-sessions/:id/group-sync", async (req) => {
|
|
26499
26713
|
webMutation(req);
|
|
26500
|
-
const identity = authorizeWeb(hub, req), { id } =
|
|
26714
|
+
const identity = authorizeWeb(hub, req), { id } = z88.object({ id: ExecutionRef }).parse(req.params);
|
|
26501
26715
|
new MemberSessions(hub).get(identity, id);
|
|
26502
|
-
const { enabled } =
|
|
26716
|
+
const { enabled } = z88.object({ enabled: z88.boolean() }).strict().parse(req.body);
|
|
26503
26717
|
hub.db.prepare("UPDATE member_agent_sessions SET group_sync=? WHERE project_id=? AND id=?").run(Number(enabled), identity.workspaceId, id);
|
|
26504
26718
|
return { enabled };
|
|
26505
26719
|
});
|
|
@@ -26512,41 +26726,41 @@ function registerHookInbox(server, hub) {
|
|
|
26512
26726
|
async (req) => routing.pollHook(token(req.headers.authorization))
|
|
26513
26727
|
);
|
|
26514
26728
|
server.post("/api/v1/event-hooks/inbox/:id/ack", async (req) => {
|
|
26515
|
-
const { id } =
|
|
26729
|
+
const { id } = z88.object({ id: z88.uuid() }).parse(req.params);
|
|
26516
26730
|
return routing.ackHook(token(req.headers.authorization), id);
|
|
26517
26731
|
});
|
|
26518
26732
|
}
|
|
26519
26733
|
|
|
26520
26734
|
// apps/server/member-execution/routes.ts
|
|
26521
|
-
import { z as
|
|
26735
|
+
import { z as z91 } from "zod";
|
|
26522
26736
|
|
|
26523
26737
|
// apps/server/member-execution/consult.ts
|
|
26524
|
-
import { z as
|
|
26738
|
+
import { z as z90 } from "zod";
|
|
26525
26739
|
|
|
26526
26740
|
// packages/protocol/external-tools.ts
|
|
26527
|
-
import { z as
|
|
26528
|
-
var ToolCatalogSchema =
|
|
26529
|
-
tools:
|
|
26530
|
-
|
|
26531
|
-
name:
|
|
26532
|
-
description:
|
|
26533
|
-
inputSchema:
|
|
26534
|
-
annotations:
|
|
26535
|
-
readOnlyHint:
|
|
26536
|
-
destructiveHint:
|
|
26537
|
-
idempotentHint:
|
|
26538
|
-
openWorldHint:
|
|
26741
|
+
import { z as z89 } from "zod";
|
|
26742
|
+
var ToolCatalogSchema = z89.object({
|
|
26743
|
+
tools: z89.array(
|
|
26744
|
+
z89.object({
|
|
26745
|
+
name: z89.string(),
|
|
26746
|
+
description: z89.string(),
|
|
26747
|
+
inputSchema: z89.object({ type: z89.literal("object") }).passthrough(),
|
|
26748
|
+
annotations: z89.object({
|
|
26749
|
+
readOnlyHint: z89.boolean(),
|
|
26750
|
+
destructiveHint: z89.boolean(),
|
|
26751
|
+
idempotentHint: z89.boolean(),
|
|
26752
|
+
openWorldHint: z89.boolean()
|
|
26539
26753
|
})
|
|
26540
26754
|
})
|
|
26541
26755
|
)
|
|
26542
26756
|
});
|
|
26543
|
-
var ToolResultSchema =
|
|
26544
|
-
var AskTeammySchema =
|
|
26545
|
-
text:
|
|
26546
|
-
conversationId:
|
|
26547
|
-
requestId:
|
|
26757
|
+
var ToolResultSchema = z89.object({ result: z89.unknown() });
|
|
26758
|
+
var AskTeammySchema = z89.object({
|
|
26759
|
+
text: z89.string().trim().min(1),
|
|
26760
|
+
conversationId: z89.uuid().optional(),
|
|
26761
|
+
requestId: z89.string().trim().min(1).max(200)
|
|
26548
26762
|
}).strict();
|
|
26549
|
-
var TeammyReplyQuerySchema =
|
|
26763
|
+
var TeammyReplyQuerySchema = z89.object({ conversationId: z89.uuid(), runId: z89.uuid() }).strict();
|
|
26550
26764
|
|
|
26551
26765
|
// apps/server/member-execution/team-consultations.ts
|
|
26552
26766
|
var TeamConsultations = class {
|
|
@@ -26595,14 +26809,14 @@ var TeamConsultations = class {
|
|
|
26595
26809
|
};
|
|
26596
26810
|
|
|
26597
26811
|
// apps/server/member-execution/consult.ts
|
|
26598
|
-
var ConsultSchema =
|
|
26812
|
+
var ConsultSchema = z90.object({
|
|
26599
26813
|
inputId: ExecutionRef,
|
|
26600
|
-
requestId:
|
|
26601
|
-
text:
|
|
26602
|
-
conversationId:
|
|
26814
|
+
requestId: z90.string().min(1).max(160),
|
|
26815
|
+
text: z90.string().trim().min(1),
|
|
26816
|
+
conversationId: z90.uuid().optional()
|
|
26603
26817
|
}).strict();
|
|
26604
26818
|
function readTeamConsultation(hub, identity, body) {
|
|
26605
|
-
const value =
|
|
26819
|
+
const value = z90.object({ conversationId: z90.uuid(), runId: z90.uuid() }).strict().parse(body);
|
|
26606
26820
|
const details2 = hub.db.prepare("SELECT details_json FROM agent_run_details WHERE run_id=?").get(value.runId);
|
|
26607
26821
|
const input = details2 && JSON.parse(String(details2.details_json)).localExecution?.inputId;
|
|
26608
26822
|
if (!input) throw new HubError(404, "TEAM_CONSULTATION_NOT_FOUND", "\u627E\u4E0D\u5230\u6258\u7BA1\u54A8\u8BE2\u3002");
|
|
@@ -26654,7 +26868,8 @@ function registerMemberExecution(server, hub, previews) {
|
|
|
26654
26868
|
});
|
|
26655
26869
|
server.get("/web/local-agent-sessions/:id/events", async (request, reply) => {
|
|
26656
26870
|
const identity = authorizeWeb(hub, request), session = id(request.params);
|
|
26657
|
-
|
|
26871
|
+
const updatesOnly = z91.object({ updates: z91.literal("1").optional() }).parse(request.query).updates === "1";
|
|
26872
|
+
let cursor = sessions2.eventCursor(identity, session);
|
|
26658
26873
|
reply.hijack();
|
|
26659
26874
|
const response = reply.raw;
|
|
26660
26875
|
response.writeHead(200, {
|
|
@@ -26663,21 +26878,29 @@ function registerMemberExecution(server, hub, previews) {
|
|
|
26663
26878
|
connection: "keep-alive",
|
|
26664
26879
|
"x-accel-buffering": "no"
|
|
26665
26880
|
});
|
|
26666
|
-
const send2 = () =>
|
|
26667
|
-
`id: ${
|
|
26881
|
+
const send2 = () => {
|
|
26882
|
+
if (updatesOnly) response.write(`id: ${cursor}
|
|
26883
|
+
event: change
|
|
26884
|
+
data: ${cursor}
|
|
26885
|
+
|
|
26886
|
+
`);
|
|
26887
|
+
else
|
|
26888
|
+
response.write(
|
|
26889
|
+
`id: ${cursor}
|
|
26668
26890
|
event: snapshot
|
|
26669
|
-
data: ${JSON.stringify(
|
|
26891
|
+
data: ${JSON.stringify(sessions2.chat(identity, session, { from: 1 }))}
|
|
26670
26892
|
|
|
26671
26893
|
`
|
|
26672
|
-
|
|
26894
|
+
);
|
|
26895
|
+
};
|
|
26673
26896
|
streams.add(response);
|
|
26674
26897
|
send2();
|
|
26675
26898
|
let ping = Date.now();
|
|
26676
26899
|
const timer2 = setInterval(() => {
|
|
26677
26900
|
try {
|
|
26678
|
-
const next = sessions2.
|
|
26679
|
-
if (next
|
|
26680
|
-
|
|
26901
|
+
const next = sessions2.eventCursor(authorizeWeb(hub, request), session);
|
|
26902
|
+
if (next !== cursor) {
|
|
26903
|
+
cursor = next;
|
|
26681
26904
|
send2();
|
|
26682
26905
|
}
|
|
26683
26906
|
if (Date.now() - ping > 15e3) {
|
|
@@ -26772,10 +26995,15 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26772
26995
|
webMutation(request);
|
|
26773
26996
|
return sessions2.directorySettings(authorizeWeb(hub, request), id(request.params), request.body);
|
|
26774
26997
|
});
|
|
26775
|
-
server.get(
|
|
26776
|
-
|
|
26777
|
-
|
|
26778
|
-
|
|
26998
|
+
server.get("/web/local-agent-sessions/:id", async (request) => {
|
|
26999
|
+
const seq = z91.coerce.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
27000
|
+
const window = z91.object({
|
|
27001
|
+
before: seq.optional(),
|
|
27002
|
+
from: seq.optional(),
|
|
27003
|
+
question: z91.string().max(500).optional()
|
|
27004
|
+
}).parse(request.query);
|
|
27005
|
+
return sessions2.chat(authorizeWeb(hub, request), id(request.params), window);
|
|
27006
|
+
});
|
|
26779
27007
|
server.put("/web/local-agent-sessions/:id/metadata", async (request) => {
|
|
26780
27008
|
webMutation(request);
|
|
26781
27009
|
return sessions2.metadata(authorizeWeb(hub, request), id(request.params), request.body);
|
|
@@ -26783,7 +27011,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26783
27011
|
server.post("/web/local-agents/:id/history", async (request) => {
|
|
26784
27012
|
webMutation(request);
|
|
26785
27013
|
const identity = authorizeWeb(hub, request);
|
|
26786
|
-
const value =
|
|
27014
|
+
const value = z91.object({ id: z91.uuid(), argument: z91.string() }).parse(request.body);
|
|
26787
27015
|
return sessions2.command(identity, sessions2.directoryHistory(identity, id(request.params)), {
|
|
26788
27016
|
...value,
|
|
26789
27017
|
kind: "history"
|
|
@@ -26791,7 +27019,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26791
27019
|
});
|
|
26792
27020
|
server.get("/web/local-agents/:id/history/:command", async (request) => {
|
|
26793
27021
|
const identity = authorizeWeb(hub, request);
|
|
26794
|
-
const params2 =
|
|
27022
|
+
const params2 = z91.object({ id: z91.string(), command: z91.string() }).parse(request.params);
|
|
26795
27023
|
return sessions2.history(
|
|
26796
27024
|
identity,
|
|
26797
27025
|
sessions2.directoryHistory(identity, params2.id, params2.command),
|
|
@@ -26807,11 +27035,11 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26807
27035
|
return sessions2.read(authorizeWeb(hub, request), id(request.params));
|
|
26808
27036
|
});
|
|
26809
27037
|
server.get("/web/local-agent-sessions/:id/diff/:command", async (request) => {
|
|
26810
|
-
const params2 =
|
|
27038
|
+
const params2 = z91.object({ id: z91.string(), command: z91.uuid() }).parse(request.params);
|
|
26811
27039
|
return sessions2.diff(authorizeWeb(hub, request), params2.id, params2.command);
|
|
26812
27040
|
});
|
|
26813
27041
|
server.get("/web/local-agent-sessions/:id/history/:command", async (request) => {
|
|
26814
|
-
const params2 =
|
|
27042
|
+
const params2 = z91.object({ id: z91.string(), command: z91.uuid() }).parse(request.params);
|
|
26815
27043
|
return sessions2.history(authorizeWeb(hub, request), params2.id, params2.command);
|
|
26816
27044
|
});
|
|
26817
27045
|
server.post("/web/local-agent-sessions/:id/commands", async (request) => {
|
|
@@ -26821,13 +27049,13 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26821
27049
|
server.post("/web/local-agent-sessions/:id/messages", async (request) => {
|
|
26822
27050
|
webMutation(request);
|
|
26823
27051
|
const identity = authorizeWeb(hub, request), session = sessions2.get(identity, id(request.params));
|
|
26824
|
-
const value =
|
|
26825
|
-
id:
|
|
26826
|
-
body:
|
|
26827
|
-
delivery:
|
|
26828
|
-
images:
|
|
26829
|
-
attachments:
|
|
26830
|
-
skills:
|
|
27052
|
+
const value = z91.object({
|
|
27053
|
+
id: z91.uuid(),
|
|
27054
|
+
body: z91.string().trim().max(2e5),
|
|
27055
|
+
delivery: z91.enum(["auto", "queue"]).optional(),
|
|
27056
|
+
images: z91.array(z91.uuid()).max(MAX_SESSION_IMAGES).default([]),
|
|
27057
|
+
attachments: z91.array(z91.uuid()).max(MAX_SESSION_IMAGES).default([]),
|
|
27058
|
+
skills: z91.array(z91.object({ name: z91.string(), path: z91.string() })).optional()
|
|
26831
27059
|
}).parse(request.body);
|
|
26832
27060
|
if (!store.sessionCapable(identity, session.directory))
|
|
26833
27061
|
throw new HubError(409, "CLIENT_UPGRADE", "\u8BF7\u5347\u7EA7\u5BA2\u6237\u7AEF\u540E\u4F7F\u7528\u7535\u8111\u4F1A\u8BDD\u3002");
|
|
@@ -26881,7 +27109,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26881
27109
|
}
|
|
26882
27110
|
});
|
|
26883
27111
|
});
|
|
26884
|
-
const questionParams =
|
|
27112
|
+
const questionParams = z91.object({ id: z91.string(), question: z91.string() });
|
|
26885
27113
|
server.post("/web/local-agent-sessions/:id/questions/:question/presented", async (request) => {
|
|
26886
27114
|
webMutation(request);
|
|
26887
27115
|
const params2 = questionParams.parse(request.params);
|
|
@@ -26890,13 +27118,13 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26890
27118
|
server.post("/web/local-agent-sessions/:id/questions/:question/answers", async (request) => {
|
|
26891
27119
|
webMutation(request);
|
|
26892
27120
|
const identity = authorizeWeb(hub, request), params2 = questionParams.parse(request.params);
|
|
26893
|
-
const value =
|
|
26894
|
-
id:
|
|
26895
|
-
body:
|
|
26896
|
-
decision:
|
|
26897
|
-
actionId:
|
|
26898
|
-
selections:
|
|
26899
|
-
answers:
|
|
27121
|
+
const value = z91.object({
|
|
27122
|
+
id: z91.uuid(),
|
|
27123
|
+
body: z91.string().trim().min(1),
|
|
27124
|
+
decision: z91.boolean().optional(),
|
|
27125
|
+
actionId: z91.string().max(100).optional(),
|
|
27126
|
+
selections: z91.record(z91.string(), z91.array(z91.string().max(500)).max(20)).optional(),
|
|
27127
|
+
answers: z91.record(z91.string(), z91.string().max(12e3)).optional()
|
|
26900
27128
|
}).parse(request.body);
|
|
26901
27129
|
const session = sessions2.get(identity, params2.id), question = sessions2.question(identity, params2.id, params2.question);
|
|
26902
27130
|
const content = JSON.parse(String(question.content_json));
|
|
@@ -26971,7 +27199,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26971
27199
|
"/local-agent/event-reply",
|
|
26972
27200
|
async (request) => replyToRoutedRequest(hub, authorizeDevice(hub, request), request.body)
|
|
26973
27201
|
);
|
|
26974
|
-
const id = (params2) =>
|
|
27202
|
+
const id = (params2) => z91.object({ id: ExecutionRef }).parse(params2).id;
|
|
26975
27203
|
server.get("/local-agent/directories", async (request) => ({
|
|
26976
27204
|
directories: store.directories(authorizeDevice(hub, request)).map(({ deviceId: _, ...directory }) => directory)
|
|
26977
27205
|
}));
|
|
@@ -26989,7 +27217,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
26989
27217
|
);
|
|
26990
27218
|
server.get("/local-agent/inputs", async (request) => {
|
|
26991
27219
|
const identity = authorizeDevice(hub, request);
|
|
26992
|
-
const query2 =
|
|
27220
|
+
const query2 = z91.object({ instance: z91.uuid(), cursor: z91.coerce.number().int().nonnegative().default(0) }).parse(request.query);
|
|
26993
27221
|
return store.poll(identity, query2.instance, query2.cursor);
|
|
26994
27222
|
});
|
|
26995
27223
|
server.get(
|
|
@@ -27027,10 +27255,10 @@ data: ${JSON.stringify(snapshot)}
|
|
|
27027
27255
|
server.get("/web/local-agents", async (request) => ({
|
|
27028
27256
|
directories: store.directories(authorizeWeb(hub, request))
|
|
27029
27257
|
}));
|
|
27030
|
-
const codeInput =
|
|
27258
|
+
const codeInput = z91.object({
|
|
27031
27259
|
directory: ExecutionRef,
|
|
27032
27260
|
session: ExecutionRef.optional(),
|
|
27033
|
-
expectedRevision:
|
|
27261
|
+
expectedRevision: z91.number().int().nonnegative()
|
|
27034
27262
|
}).strict();
|
|
27035
27263
|
server.post("/web/local-agent-bindings/codes", async (request) => {
|
|
27036
27264
|
webMutation(request);
|
|
@@ -27064,7 +27292,7 @@ data: ${JSON.stringify(snapshot)}
|
|
|
27064
27292
|
async (request) => bridge.messageStatus(authorizeDevice(hub, request), id(request.params))
|
|
27065
27293
|
);
|
|
27066
27294
|
server.post("/local-agent/questions/:id/reserve", async (request) => {
|
|
27067
|
-
const value =
|
|
27295
|
+
const value = z91.object({ replyContext: ExecutionRef }).strict().parse(request.body);
|
|
27068
27296
|
return bridge.reserveQuestion(
|
|
27069
27297
|
authorizeDevice(hub, request),
|
|
27070
27298
|
id(request.params),
|
|
@@ -27202,7 +27430,7 @@ function buildServer(options) {
|
|
|
27202
27430
|
return reply.code(status).send(body);
|
|
27203
27431
|
});
|
|
27204
27432
|
server.get("/healthz", async () => ({ status: "ok" }));
|
|
27205
|
-
registerClientRelease(server);
|
|
27433
|
+
const clientUpdateTarget = registerClientRelease(server, options.version, options.dataDir);
|
|
27206
27434
|
server.get("/api/v1/server", async () => ({
|
|
27207
27435
|
name: "teammy",
|
|
27208
27436
|
version: options.version,
|
|
@@ -27281,7 +27509,7 @@ function buildServer(options) {
|
|
|
27281
27509
|
registerProjectScopeRoutes(scope2, store);
|
|
27282
27510
|
registerAiJobRoutes(scope2, store);
|
|
27283
27511
|
registerTaskRoutes(scope2, store);
|
|
27284
|
-
registerControlRoutes(scope2, store);
|
|
27512
|
+
registerControlRoutes(scope2, store, clientUpdateTarget);
|
|
27285
27513
|
registerFileRoutes(scope2, store);
|
|
27286
27514
|
registerMaterialRoutes(scope2, store);
|
|
27287
27515
|
registerMemoryRoutes(scope2, store);
|
|
@@ -27308,7 +27536,7 @@ function buildServer(options) {
|
|
|
27308
27536
|
|
|
27309
27537
|
// apps/server/main.ts
|
|
27310
27538
|
import { homedir } from "node:os";
|
|
27311
|
-
import { join as
|
|
27539
|
+
import { join as join31, resolve as resolve6 } from "node:path";
|
|
27312
27540
|
import { spawn as spawn4 } from "node:child_process";
|
|
27313
27541
|
var help = `teammy-server \u2014 the Teammy collaboration hub
|
|
27314
27542
|
|
|
@@ -27353,7 +27581,7 @@ async function runServerCli(args, version2) {
|
|
|
27353
27581
|
confirm: { type: "boolean" },
|
|
27354
27582
|
"data-dir": {
|
|
27355
27583
|
type: "string",
|
|
27356
|
-
default: process.env.TEAMMY_DATA_DIR ??
|
|
27584
|
+
default: process.env.TEAMMY_DATA_DIR ?? join31(homedir(), ".teammy", "server")
|
|
27357
27585
|
}
|
|
27358
27586
|
}
|
|
27359
27587
|
});
|
|
@@ -27376,7 +27604,7 @@ async function runServerCli(args, version2) {
|
|
|
27376
27604
|
options: {
|
|
27377
27605
|
"data-dir": {
|
|
27378
27606
|
type: "string",
|
|
27379
|
-
default: process.env.TEAMMY_DATA_DIR ??
|
|
27607
|
+
default: process.env.TEAMMY_DATA_DIR ?? join31(homedir(), ".teammy", "server")
|
|
27380
27608
|
},
|
|
27381
27609
|
once: { type: "boolean" }
|
|
27382
27610
|
}
|
|
@@ -27395,7 +27623,7 @@ async function runServerCli(args, version2) {
|
|
|
27395
27623
|
member: { type: "string" },
|
|
27396
27624
|
"data-dir": {
|
|
27397
27625
|
type: "string",
|
|
27398
|
-
default: process.env.TEAMMY_DATA_DIR ??
|
|
27626
|
+
default: process.env.TEAMMY_DATA_DIR ?? join31(homedir(), ".teammy", "server")
|
|
27399
27627
|
}
|
|
27400
27628
|
}
|
|
27401
27629
|
});
|
|
@@ -27423,7 +27651,7 @@ async function runServerCli(args, version2) {
|
|
|
27423
27651
|
port: { type: "string", default: process.env.TEAMMY_PORT ?? "4317" },
|
|
27424
27652
|
"data-dir": {
|
|
27425
27653
|
type: "string",
|
|
27426
|
-
default: process.env.TEAMMY_DATA_DIR ??
|
|
27654
|
+
default: process.env.TEAMMY_DATA_DIR ?? join31(homedir(), ".teammy", "server")
|
|
27427
27655
|
},
|
|
27428
27656
|
"with-worker": { type: "boolean", default: false }
|
|
27429
27657
|
}
|