tianshu-harness 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +189 -0
- package/README.en.md +1066 -0
- package/README.ja.md +1214 -0
- package/README.ko.md +1216 -0
- package/README.md +309 -0
- package/completions/rivet.bash +118 -0
- package/completions/rivet.fish +110 -0
- package/completions/rivet.ps1 +230 -0
- package/completions/rivet.zsh +187 -0
- package/dist/account-OAEKORZE.js +47 -0
- package/dist/account-login-V6FOLHJR.js +65 -0
- package/dist/account-status-KHNPPAFL.js +23 -0
- package/dist/agent/worker-process/child.js +407 -0
- package/dist/browser-cli-FLNY5ZHI.js +19 -0
- package/dist/browser-readiness-LWVGSBD5.js +12 -0
- package/dist/build-backends-5KXKR2S4.js +13 -0
- package/dist/build-options-66Y4ZE7C.js +9 -0
- package/dist/bundled-skills/brainstorming/SKILL.md +139 -0
- package/dist/bundled-skills/visual-acceptance/SKILL.md +64 -0
- package/dist/chain-7MAMFXZ3.js +10 -0
- package/dist/checkpoint-MND4DUIX.js +33 -0
- package/dist/chunk-2E6CK2RC.js +392 -0
- package/dist/chunk-2EBWGAXD.js +51 -0
- package/dist/chunk-2HDP7RMR.js +119 -0
- package/dist/chunk-2HKD2UFM.js +1000 -0
- package/dist/chunk-2VYRLULP.js +51 -0
- package/dist/chunk-2XN7PM4N.js +125 -0
- package/dist/chunk-35H7GVNR.js +66 -0
- package/dist/chunk-3C3R7JXY.js +77 -0
- package/dist/chunk-3VGD2FXB.js +118 -0
- package/dist/chunk-424AP7FM.js +534 -0
- package/dist/chunk-4J5TZGOE.js +3707 -0
- package/dist/chunk-4QJ3Y5JM.js +898 -0
- package/dist/chunk-4U2ET7ZY.js +1326 -0
- package/dist/chunk-4XPFLICE.js +876 -0
- package/dist/chunk-5B2OCU5P.js +31707 -0
- package/dist/chunk-5GGOGLSN.js +73 -0
- package/dist/chunk-5JRZPLI6.js +251 -0
- package/dist/chunk-5TQ3JYBU.js +397 -0
- package/dist/chunk-66JPZSGX.js +55 -0
- package/dist/chunk-6HSVXHCZ.js +764 -0
- package/dist/chunk-6S5FPUS7.js +21 -0
- package/dist/chunk-722LQO64.js +131 -0
- package/dist/chunk-73NJ7IT7.js +354 -0
- package/dist/chunk-7FW3I7WC.js +95 -0
- package/dist/chunk-7KUCBNLB.js +173 -0
- package/dist/chunk-7RDOV3DF.js +201 -0
- package/dist/chunk-A5MNH4ER.js +79 -0
- package/dist/chunk-ADIVZ2D5.js +15 -0
- package/dist/chunk-AE3P3F6W.js +366 -0
- package/dist/chunk-AERM3VGP.js +280 -0
- package/dist/chunk-AEWHC4WM.js +246 -0
- package/dist/chunk-AOVQ7VIF.js +169 -0
- package/dist/chunk-AOYHP3WI.js +12411 -0
- package/dist/chunk-B3YEBABJ.js +7160 -0
- package/dist/chunk-BCQXEZPJ.js +154 -0
- package/dist/chunk-BKTQAYO2.js +418 -0
- package/dist/chunk-BSECIPAQ.js +80 -0
- package/dist/chunk-BUIMGNDD.js +52 -0
- package/dist/chunk-BXHV3GSB.js +10320 -0
- package/dist/chunk-C6ZVZCPP.js +139 -0
- package/dist/chunk-CEZNQVWM.js +82 -0
- package/dist/chunk-CGFZGR7G.js +1492 -0
- package/dist/chunk-CGOADM2X.js +337 -0
- package/dist/chunk-CI4R6P2B.js +24 -0
- package/dist/chunk-D2TCGRSX.js +73 -0
- package/dist/chunk-D4PTYFOG.js +154 -0
- package/dist/chunk-D54ZWG4T.js +717 -0
- package/dist/chunk-DEBI37QB.js +145 -0
- package/dist/chunk-DWROHPXP.js +1051 -0
- package/dist/chunk-DZ6UOJ5D.js +92 -0
- package/dist/chunk-EBJTVRQN.js +81 -0
- package/dist/chunk-EGEI2RQA.js +1167 -0
- package/dist/chunk-EHHUASO5.js +1305 -0
- package/dist/chunk-EPKTIOED.js +41 -0
- package/dist/chunk-ER5JW2QZ.js +5681 -0
- package/dist/chunk-ETHFACAB.js +315 -0
- package/dist/chunk-EXUE5W2F.js +112 -0
- package/dist/chunk-EXXICUIW.js +73 -0
- package/dist/chunk-FFQSZJOO.js +169 -0
- package/dist/chunk-FHFKPGDO.js +85 -0
- package/dist/chunk-FW3QKMFX.js +158 -0
- package/dist/chunk-GD4ZNZ7W.js +30 -0
- package/dist/chunk-GHVMWF2I.js +581 -0
- package/dist/chunk-GMKAXSYQ.js +297 -0
- package/dist/chunk-HBVF6BWO.js +325 -0
- package/dist/chunk-HV4YGVMS.js +379 -0
- package/dist/chunk-ILBCKAV6.js +89 -0
- package/dist/chunk-J4U4AW46.js +440 -0
- package/dist/chunk-J6ESSM47.js +1791 -0
- package/dist/chunk-JBZHIC6T.js +2309 -0
- package/dist/chunk-JCFWOULR.js +245 -0
- package/dist/chunk-JRF5L6OD.js +131 -0
- package/dist/chunk-JSS75KCG.js +2014 -0
- package/dist/chunk-JSXWIWWJ.js +225 -0
- package/dist/chunk-JYV7I2QH.js +98 -0
- package/dist/chunk-KIOXTQQL.js +1596 -0
- package/dist/chunk-KWVTXT5B.js +89 -0
- package/dist/chunk-KX22RD6R.js +33 -0
- package/dist/chunk-LA6IPTGH.js +709 -0
- package/dist/chunk-LH5VCGLB.js +1796 -0
- package/dist/chunk-LQQ6XJ2Y.js +269 -0
- package/dist/chunk-MJQ55WZZ.js +65 -0
- package/dist/chunk-ML3UKMH3.js +40 -0
- package/dist/chunk-MOZPLHSU.js +5526 -0
- package/dist/chunk-NGEWJ4DF.js +89 -0
- package/dist/chunk-NH6VIOAR.js +211 -0
- package/dist/chunk-O5VZQKCB.js +26106 -0
- package/dist/chunk-OHSV42QB.js +748 -0
- package/dist/chunk-OO3TAHO5.js +4070 -0
- package/dist/chunk-OTNHSAGN.js +38282 -0
- package/dist/chunk-OUWAC7AQ.js +442 -0
- package/dist/chunk-OXMIV4WE.js +270 -0
- package/dist/chunk-P5KJURUR.js +229 -0
- package/dist/chunk-P6GJOVO6.js +307 -0
- package/dist/chunk-QARAGUXX.js +23 -0
- package/dist/chunk-R43HJCDX.js +2711 -0
- package/dist/chunk-RAXBAWRN.js +210 -0
- package/dist/chunk-RK3JHWPT.js +39 -0
- package/dist/chunk-RWA23GMM.js +24 -0
- package/dist/chunk-S4K4L6IM.js +179 -0
- package/dist/chunk-SAXK6LVF.js +124 -0
- package/dist/chunk-SEPGEJNK.js +1607 -0
- package/dist/chunk-SUJERP5I.js +285 -0
- package/dist/chunk-T3ED6BY2.js +913 -0
- package/dist/chunk-THKDVSEC.js +90 -0
- package/dist/chunk-TI4GSEL5.js +52 -0
- package/dist/chunk-TPI73L57.js +164 -0
- package/dist/chunk-TVHW77C7.js +338 -0
- package/dist/chunk-TWNHOSDT.js +1073 -0
- package/dist/chunk-UFMN76QD.js +347 -0
- package/dist/chunk-UHGLFRZE.js +205 -0
- package/dist/chunk-UTZYPKBF.js +15231 -0
- package/dist/chunk-UXNLELW6.js +25 -0
- package/dist/chunk-UXXS53EA.js +166 -0
- package/dist/chunk-V5DHFGI7.js +171 -0
- package/dist/chunk-V5YIPMHV.js +2353 -0
- package/dist/chunk-WMUWEO2C.js +754 -0
- package/dist/chunk-WOE3D7JM.js +945 -0
- package/dist/chunk-X2IK5LVR.js +2592 -0
- package/dist/chunk-XU2YXCDL.js +459 -0
- package/dist/chunk-YJG5HIX5.js +203 -0
- package/dist/chunk-Z3QE7TZM.js +72 -0
- package/dist/chunk-Z5Z3JHJY.js +64 -0
- package/dist/chunk-ZDIFBJFT.js +168 -0
- package/dist/chunk-ZGGCEXDC.js +176 -0
- package/dist/chunk-ZMZCZNKU.js +263 -0
- package/dist/chunk-ZNC5T65N.js +17 -0
- package/dist/chunk-ZO3I3A7O.js +308 -0
- package/dist/chunk-ZQKXBUB7.js +217 -0
- package/dist/chunk-ZTRINFM2.js +78 -0
- package/dist/chunk-ZU7JZCVP.js +193 -0
- package/dist/chunk-ZZAWNALS.js +350 -0
- package/dist/cli/entry.js +54 -0
- package/dist/connector-L5QQTR6Y.js +26 -0
- package/dist/context-62DC6EC3.js +31 -0
- package/dist/council-convene-NJWPNBDU.js +46 -0
- package/dist/create-agent-config-ODSQWNVC.js +55 -0
- package/dist/default-registry-2PU3BTAU.js +68 -0
- package/dist/deliver-task-KONV4C4M.js +57 -0
- package/dist/delivery-gate-v2-F2YVMVGK.js +27 -0
- package/dist/domain-knowledge-store-DDZ3F4J7.js +11 -0
- package/dist/fetch-core-ZPPYDSZH.js +14 -0
- package/dist/galaxy-K72BBDQN.js +91 -0
- package/dist/goal-criteria-SCALAU2D.js +141 -0
- package/dist/goal-persist-XWY2GDQX.js +19 -0
- package/dist/goal-tracker-FXMJ2GVK.js +11 -0
- package/dist/headless-LSB6I7PT.js +162 -0
- package/dist/headless-coordinator-VDPDMVUT.js +90 -0
- package/dist/inject-U55SMB6A.js +39 -0
- package/dist/login-flow-CD4ZGXOC.js +59 -0
- package/dist/logs-cli-SQVYFMMN.js +283 -0
- package/dist/loop-ULZYBDA3.js +76 -0
- package/dist/main.js +4064 -0
- package/dist/manager-ROZBCWPA.js +171 -0
- package/dist/manager-Z7XFFUOM.js +10670 -0
- package/dist/meridian-indexer-ZIW363L7.js +21 -0
- package/dist/native-resolver-PN34UIVV.js +13 -0
- package/dist/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/node_modules/better-sqlite3/package.json +59 -0
- package/dist/ownership-ledger-E3WIEKPL.js +9 -0
- package/dist/package.json +3 -0
- package/dist/path-grants-XRRXHXG7.js +40 -0
- package/dist/paths-LVV5IMQN.js +49 -0
- package/dist/plan-fact-anchors-LMVQZCW5.js +13 -0
- package/dist/plan-store-ODLTTPFB.js +17 -0
- package/dist/plan-templates-5FPFBOL6.js +109 -0
- package/dist/plugin-loader-ZZKX7ZE6.js +22 -0
- package/dist/prefix-budget-62OV5HQC.js +13 -0
- package/dist/project-trust-5WS5MOMU.js +31 -0
- package/dist/provider-cli-ALDQXIT7.js +37 -0
- package/dist/providers-XQYTAVPK.js +11 -0
- package/dist/proxy-resolver-V2Y6534D.js +15 -0
- package/dist/recovery-cli-KPGY6FY3.js +106 -0
- package/dist/review-discipline-MNSYCST5.js +55 -0
- package/dist/review-router-BVQZW3MX.js +18 -0
- package/dist/seed-capsules/seed-capsule-attack-methodology.md +62 -0
- package/dist/seed-capsules/seed-capsule-changgeng.md +31 -0
- package/dist/seed-capsules/seed-capsule-design-aesthetics.md +38 -0
- package/dist/seed-capsules/seed-capsule-diagnostic-ladder.md +54 -0
- package/dist/seed-capsules/seed-capsule-fu.md +39 -0
- package/dist/seed-capsules/seed-capsule-huagai.md +73 -0
- package/dist/seed-capsules/seed-capsule-kaiyang.md +65 -0
- package/dist/seed-capsules/seed-capsule-knowledge-work.md +40 -0
- package/dist/seed-capsules/seed-capsule-tanlang.md +47 -0
- package/dist/seed-capsules/seed-capsule-tianfu.md +23 -0
- package/dist/seed-capsules/seed-capsule-tianliang.md +63 -0
- package/dist/seed-capsules/seed-capsule-tianquan.md +32 -0
- package/dist/seed-capsules/seed-capsule-tianxuan-ccr.md +22 -0
- package/dist/seed-capsules/seed-capsule-tianxuan.md +64 -0
- package/dist/seed-capsules/seed-capsule-yaoguang.md +87 -0
- package/dist/serve-X2R2UTLF.js +170 -0
- package/dist/serve-agent-KHSU6RVV.js +965 -0
- package/dist/session-persist-HUUC772H.js +37 -0
- package/dist/session-registry-6XUD5C4Y.js +15 -0
- package/dist/skill-loader-CK3RMO47.js +48 -0
- package/dist/skills/cli-harness-sop.md +207 -0
- package/dist/spawn-git-4HFU65AH.js +29 -0
- package/dist/sse-EYUTBWUK.js +512 -0
- package/dist/starflow-NOFBMPFU.js +30 -0
- package/dist/streamableHttp-V67CNJMO.js +447 -0
- package/dist/task-contract-6XHBNJQK.js +32 -0
- package/dist/task-ledger-3K4TJIER.js +9 -0
- package/dist/team-orchestrate-S6NHZP7X.js +64 -0
- package/dist/title-extract-QX4XGCYN.js +50 -0
- package/dist/todo-QDXGRZZP.js +31 -0
- package/dist/todo-store-V3TTO5AH.js +12 -0
- package/dist/tool-preset-LU5BYEDZ.js +23 -0
- package/dist/tool-tiers-GD742YBN.js +23 -0
- package/dist/turndown.es-OI55K6C3.js +17373 -0
- package/dist/verification-attribution-EKG4CNUV.js +13 -0
- package/dist/volatile-git-MBTST7RA.js +15 -0
- package/dist/wave-checkpoint-XLIIHXQA.js +30 -0
- package/dist/web-cli-DUG4I35O.js +233 -0
- package/dist/web-search-3IK542AA.js +34 -0
- package/dist/workers/cpu-worker.js +45 -0
- package/dist/workflow-runner-HX7UBAYG.js +297 -0
- package/dist/worktree-baseline-O5NCU6M2.js +9 -0
- package/package.json +122 -0
- package/scripts/check-mobile-env.mjs +76 -0
- package/scripts/fetch-native-sqlite.js +392 -0
- package/scripts/prune-installed-wasms.js +45 -0
- package/scripts/tree-sitter-wasm-keep.js +40 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
UnauthorizedError,
|
|
5
|
+
auth,
|
|
6
|
+
createFetchWithInit,
|
|
7
|
+
createParser,
|
|
8
|
+
extractWWWAuthenticateParams,
|
|
9
|
+
normalizeHeaders
|
|
10
|
+
} from "./chunk-TWNHOSDT.js";
|
|
11
|
+
import {
|
|
12
|
+
JSONRPCMessageSchema,
|
|
13
|
+
isInitializedNotification,
|
|
14
|
+
isJSONRPCRequest,
|
|
15
|
+
isJSONRPCResultResponse
|
|
16
|
+
} from "./chunk-MOZPLHSU.js";
|
|
17
|
+
import {
|
|
18
|
+
init_esm_shims
|
|
19
|
+
} from "./chunk-5GGOGLSN.js";
|
|
20
|
+
|
|
21
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
22
|
+
init_esm_shims();
|
|
23
|
+
|
|
24
|
+
// node_modules/eventsource-parser/dist/stream.js
|
|
25
|
+
init_esm_shims();
|
|
26
|
+
var EventSourceParserStream = class extends TransformStream {
|
|
27
|
+
constructor({ onError, onRetry, onComment } = {}) {
|
|
28
|
+
let parser;
|
|
29
|
+
super({
|
|
30
|
+
start(controller) {
|
|
31
|
+
parser = createParser({
|
|
32
|
+
onEvent: (event) => {
|
|
33
|
+
controller.enqueue(event);
|
|
34
|
+
},
|
|
35
|
+
onError(error) {
|
|
36
|
+
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
37
|
+
},
|
|
38
|
+
onRetry,
|
|
39
|
+
onComment
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
transform(chunk) {
|
|
43
|
+
parser.feed(chunk);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
50
|
+
var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
51
|
+
initialReconnectionDelay: 1e3,
|
|
52
|
+
maxReconnectionDelay: 3e4,
|
|
53
|
+
reconnectionDelayGrowFactor: 1.5,
|
|
54
|
+
maxRetries: 2
|
|
55
|
+
};
|
|
56
|
+
var StreamableHTTPError = class extends Error {
|
|
57
|
+
constructor(code, message) {
|
|
58
|
+
super(`Streamable HTTP error: ${message}`);
|
|
59
|
+
this.code = code;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var StreamableHTTPClientTransport = class {
|
|
63
|
+
constructor(url, opts) {
|
|
64
|
+
this._hasCompletedAuthFlow = false;
|
|
65
|
+
this._url = url;
|
|
66
|
+
this._resourceMetadataUrl = void 0;
|
|
67
|
+
this._scope = void 0;
|
|
68
|
+
this._requestInit = opts?.requestInit;
|
|
69
|
+
this._authProvider = opts?.authProvider;
|
|
70
|
+
this._fetch = opts?.fetch;
|
|
71
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
72
|
+
this._sessionId = opts?.sessionId;
|
|
73
|
+
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
74
|
+
}
|
|
75
|
+
async _authThenStart() {
|
|
76
|
+
if (!this._authProvider) {
|
|
77
|
+
throw new UnauthorizedError("No auth provider");
|
|
78
|
+
}
|
|
79
|
+
let result;
|
|
80
|
+
try {
|
|
81
|
+
result = await auth(this._authProvider, {
|
|
82
|
+
serverUrl: this._url,
|
|
83
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
84
|
+
scope: this._scope,
|
|
85
|
+
fetchFn: this._fetchWithInit
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
this.onerror?.(error);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
if (result !== "AUTHORIZED") {
|
|
92
|
+
throw new UnauthorizedError();
|
|
93
|
+
}
|
|
94
|
+
return await this._startOrAuthSse({ resumptionToken: void 0 });
|
|
95
|
+
}
|
|
96
|
+
async _commonHeaders() {
|
|
97
|
+
const headers = {};
|
|
98
|
+
if (this._authProvider) {
|
|
99
|
+
const tokens = await this._authProvider.tokens();
|
|
100
|
+
if (tokens) {
|
|
101
|
+
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (this._sessionId) {
|
|
105
|
+
headers["mcp-session-id"] = this._sessionId;
|
|
106
|
+
}
|
|
107
|
+
if (this._protocolVersion) {
|
|
108
|
+
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
109
|
+
}
|
|
110
|
+
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
111
|
+
return new Headers({
|
|
112
|
+
...headers,
|
|
113
|
+
...extraHeaders
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async _startOrAuthSse(options) {
|
|
117
|
+
const { resumptionToken } = options;
|
|
118
|
+
try {
|
|
119
|
+
const headers = await this._commonHeaders();
|
|
120
|
+
headers.set("Accept", "text/event-stream");
|
|
121
|
+
if (resumptionToken) {
|
|
122
|
+
headers.set("last-event-id", resumptionToken);
|
|
123
|
+
}
|
|
124
|
+
const response = await (this._fetch ?? fetch)(this._url, {
|
|
125
|
+
method: "GET",
|
|
126
|
+
headers,
|
|
127
|
+
signal: this._abortController?.signal
|
|
128
|
+
});
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
await response.body?.cancel();
|
|
131
|
+
if (response.status === 401 && this._authProvider) {
|
|
132
|
+
return await this._authThenStart();
|
|
133
|
+
}
|
|
134
|
+
if (response.status === 405) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
138
|
+
}
|
|
139
|
+
this._handleSseStream(response.body, options, true);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
this.onerror?.(error);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Calculates the next reconnection delay using backoff algorithm
|
|
147
|
+
*
|
|
148
|
+
* @param attempt Current reconnection attempt count for the specific stream
|
|
149
|
+
* @returns Time to wait in milliseconds before next reconnection attempt
|
|
150
|
+
*/
|
|
151
|
+
_getNextReconnectionDelay(attempt) {
|
|
152
|
+
if (this._serverRetryMs !== void 0) {
|
|
153
|
+
return this._serverRetryMs;
|
|
154
|
+
}
|
|
155
|
+
const initialDelay = this._reconnectionOptions.initialReconnectionDelay;
|
|
156
|
+
const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;
|
|
157
|
+
const maxDelay = this._reconnectionOptions.maxReconnectionDelay;
|
|
158
|
+
return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Schedule a reconnection attempt using server-provided retry interval or backoff
|
|
162
|
+
*
|
|
163
|
+
* @param lastEventId The ID of the last received event for resumability
|
|
164
|
+
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
165
|
+
*/
|
|
166
|
+
_scheduleReconnection(options, attemptCount = 0) {
|
|
167
|
+
const maxRetries = this._reconnectionOptions.maxRetries;
|
|
168
|
+
if (attemptCount >= maxRetries) {
|
|
169
|
+
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const delay = this._getNextReconnectionDelay(attemptCount);
|
|
173
|
+
this._reconnectionTimeout = setTimeout(() => {
|
|
174
|
+
this._startOrAuthSse(options).catch((error) => {
|
|
175
|
+
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
|
|
176
|
+
this._scheduleReconnection(options, attemptCount + 1);
|
|
177
|
+
});
|
|
178
|
+
}, delay);
|
|
179
|
+
}
|
|
180
|
+
_handleSseStream(stream, options, isReconnectable) {
|
|
181
|
+
if (!stream) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const { onresumptiontoken, replayMessageId } = options;
|
|
185
|
+
let lastEventId;
|
|
186
|
+
let hasPrimingEvent = false;
|
|
187
|
+
let receivedResponse = false;
|
|
188
|
+
const processStream = async () => {
|
|
189
|
+
try {
|
|
190
|
+
const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
|
|
191
|
+
onRetry: (retryMs) => {
|
|
192
|
+
this._serverRetryMs = retryMs;
|
|
193
|
+
}
|
|
194
|
+
})).getReader();
|
|
195
|
+
while (true) {
|
|
196
|
+
const { value: event, done } = await reader.read();
|
|
197
|
+
if (done) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
if (event.id) {
|
|
201
|
+
lastEventId = event.id;
|
|
202
|
+
hasPrimingEvent = true;
|
|
203
|
+
onresumptiontoken?.(event.id);
|
|
204
|
+
}
|
|
205
|
+
if (!event.data) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (!event.event || event.event === "message") {
|
|
209
|
+
try {
|
|
210
|
+
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
|
211
|
+
if (isJSONRPCResultResponse(message)) {
|
|
212
|
+
receivedResponse = true;
|
|
213
|
+
if (replayMessageId !== void 0) {
|
|
214
|
+
message.id = replayMessageId;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.onmessage?.(message);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
this.onerror?.(error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const canResume = isReconnectable || hasPrimingEvent;
|
|
224
|
+
const needsReconnect = canResume && !receivedResponse;
|
|
225
|
+
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
226
|
+
this._scheduleReconnection({
|
|
227
|
+
resumptionToken: lastEventId,
|
|
228
|
+
onresumptiontoken,
|
|
229
|
+
replayMessageId
|
|
230
|
+
}, 0);
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
this.onerror?.(new Error(`SSE stream disconnected: ${error}`));
|
|
234
|
+
const canResume = isReconnectable || hasPrimingEvent;
|
|
235
|
+
const needsReconnect = canResume && !receivedResponse;
|
|
236
|
+
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
237
|
+
try {
|
|
238
|
+
this._scheduleReconnection({
|
|
239
|
+
resumptionToken: lastEventId,
|
|
240
|
+
onresumptiontoken,
|
|
241
|
+
replayMessageId
|
|
242
|
+
}, 0);
|
|
243
|
+
} catch (error2) {
|
|
244
|
+
this.onerror?.(new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
processStream();
|
|
250
|
+
}
|
|
251
|
+
async start() {
|
|
252
|
+
if (this._abortController) {
|
|
253
|
+
throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
254
|
+
}
|
|
255
|
+
this._abortController = new AbortController();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
259
|
+
*/
|
|
260
|
+
async finishAuth(authorizationCode) {
|
|
261
|
+
if (!this._authProvider) {
|
|
262
|
+
throw new UnauthorizedError("No auth provider");
|
|
263
|
+
}
|
|
264
|
+
const result = await auth(this._authProvider, {
|
|
265
|
+
serverUrl: this._url,
|
|
266
|
+
authorizationCode,
|
|
267
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
268
|
+
scope: this._scope,
|
|
269
|
+
fetchFn: this._fetchWithInit
|
|
270
|
+
});
|
|
271
|
+
if (result !== "AUTHORIZED") {
|
|
272
|
+
throw new UnauthorizedError("Failed to authorize");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async close() {
|
|
276
|
+
if (this._reconnectionTimeout) {
|
|
277
|
+
clearTimeout(this._reconnectionTimeout);
|
|
278
|
+
this._reconnectionTimeout = void 0;
|
|
279
|
+
}
|
|
280
|
+
this._abortController?.abort();
|
|
281
|
+
this.onclose?.();
|
|
282
|
+
}
|
|
283
|
+
async send(message, options) {
|
|
284
|
+
try {
|
|
285
|
+
const { resumptionToken, onresumptiontoken } = options || {};
|
|
286
|
+
if (resumptionToken) {
|
|
287
|
+
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const headers = await this._commonHeaders();
|
|
291
|
+
headers.set("content-type", "application/json");
|
|
292
|
+
headers.set("accept", "application/json, text/event-stream");
|
|
293
|
+
const init = {
|
|
294
|
+
...this._requestInit,
|
|
295
|
+
method: "POST",
|
|
296
|
+
headers,
|
|
297
|
+
body: JSON.stringify(message),
|
|
298
|
+
signal: this._abortController?.signal
|
|
299
|
+
};
|
|
300
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
301
|
+
const sessionId = response.headers.get("mcp-session-id");
|
|
302
|
+
if (sessionId) {
|
|
303
|
+
this._sessionId = sessionId;
|
|
304
|
+
}
|
|
305
|
+
if (!response.ok) {
|
|
306
|
+
const text = await response.text().catch(() => null);
|
|
307
|
+
if (response.status === 401 && this._authProvider) {
|
|
308
|
+
if (this._hasCompletedAuthFlow) {
|
|
309
|
+
throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
|
|
310
|
+
}
|
|
311
|
+
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
312
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
313
|
+
this._scope = scope;
|
|
314
|
+
const result = await auth(this._authProvider, {
|
|
315
|
+
serverUrl: this._url,
|
|
316
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
317
|
+
scope: this._scope,
|
|
318
|
+
fetchFn: this._fetchWithInit
|
|
319
|
+
});
|
|
320
|
+
if (result !== "AUTHORIZED") {
|
|
321
|
+
throw new UnauthorizedError();
|
|
322
|
+
}
|
|
323
|
+
this._hasCompletedAuthFlow = true;
|
|
324
|
+
return this.send(message);
|
|
325
|
+
}
|
|
326
|
+
if (response.status === 403 && this._authProvider) {
|
|
327
|
+
const { resourceMetadataUrl, scope, error } = extractWWWAuthenticateParams(response);
|
|
328
|
+
if (error === "insufficient_scope") {
|
|
329
|
+
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
330
|
+
if (this._lastUpscopingHeader === wwwAuthHeader) {
|
|
331
|
+
throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
|
|
332
|
+
}
|
|
333
|
+
if (scope) {
|
|
334
|
+
this._scope = scope;
|
|
335
|
+
}
|
|
336
|
+
if (resourceMetadataUrl) {
|
|
337
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
338
|
+
}
|
|
339
|
+
this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
|
|
340
|
+
const result = await auth(this._authProvider, {
|
|
341
|
+
serverUrl: this._url,
|
|
342
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
343
|
+
scope: this._scope,
|
|
344
|
+
fetchFn: this._fetch
|
|
345
|
+
});
|
|
346
|
+
if (result !== "AUTHORIZED") {
|
|
347
|
+
throw new UnauthorizedError();
|
|
348
|
+
}
|
|
349
|
+
return this.send(message);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
353
|
+
}
|
|
354
|
+
this._hasCompletedAuthFlow = false;
|
|
355
|
+
this._lastUpscopingHeader = void 0;
|
|
356
|
+
if (response.status === 202) {
|
|
357
|
+
await response.body?.cancel();
|
|
358
|
+
if (isInitializedNotification(message)) {
|
|
359
|
+
this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const messages = Array.isArray(message) ? message : [message];
|
|
364
|
+
const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
365
|
+
const contentType = response.headers.get("content-type");
|
|
366
|
+
if (hasRequests) {
|
|
367
|
+
if (contentType?.includes("text/event-stream")) {
|
|
368
|
+
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
369
|
+
} else if (contentType?.includes("application/json")) {
|
|
370
|
+
const data = await response.json();
|
|
371
|
+
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
372
|
+
for (const msg of responseMessages) {
|
|
373
|
+
this.onmessage?.(msg);
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
await response.body?.cancel();
|
|
377
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
await response.body?.cancel();
|
|
381
|
+
}
|
|
382
|
+
} catch (error) {
|
|
383
|
+
this.onerror?.(error);
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
get sessionId() {
|
|
388
|
+
return this._sessionId;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Terminates the current session by sending a DELETE request to the server.
|
|
392
|
+
*
|
|
393
|
+
* Clients that no longer need a particular session
|
|
394
|
+
* (e.g., because the user is leaving the client application) SHOULD send an
|
|
395
|
+
* HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
|
|
396
|
+
* terminate the session.
|
|
397
|
+
*
|
|
398
|
+
* The server MAY respond with HTTP 405 Method Not Allowed, indicating that
|
|
399
|
+
* the server does not allow clients to terminate sessions.
|
|
400
|
+
*/
|
|
401
|
+
async terminateSession() {
|
|
402
|
+
if (!this._sessionId) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
const headers = await this._commonHeaders();
|
|
407
|
+
const init = {
|
|
408
|
+
...this._requestInit,
|
|
409
|
+
method: "DELETE",
|
|
410
|
+
headers,
|
|
411
|
+
signal: this._abortController?.signal
|
|
412
|
+
};
|
|
413
|
+
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
414
|
+
await response.body?.cancel();
|
|
415
|
+
if (!response.ok && response.status !== 405) {
|
|
416
|
+
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
417
|
+
}
|
|
418
|
+
this._sessionId = void 0;
|
|
419
|
+
} catch (error) {
|
|
420
|
+
this.onerror?.(error);
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
setProtocolVersion(version) {
|
|
425
|
+
this._protocolVersion = version;
|
|
426
|
+
}
|
|
427
|
+
get protocolVersion() {
|
|
428
|
+
return this._protocolVersion;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Resume an SSE stream from a previous event ID.
|
|
432
|
+
* Opens a GET SSE connection with Last-Event-ID header to replay missed events.
|
|
433
|
+
*
|
|
434
|
+
* @param lastEventId The event ID to resume from
|
|
435
|
+
* @param options Optional callback to receive new resumption tokens
|
|
436
|
+
*/
|
|
437
|
+
async resumeStream(lastEventId, options) {
|
|
438
|
+
await this._startOrAuthSse({
|
|
439
|
+
resumptionToken: lastEventId,
|
|
440
|
+
onresumptiontoken: options?.onresumptiontoken
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
export {
|
|
445
|
+
StreamableHTTPClientTransport,
|
|
446
|
+
StreamableHTTPError
|
|
447
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
advanceContractStatus,
|
|
5
|
+
classifyPlanMethodology,
|
|
6
|
+
classifyTaskDepth,
|
|
7
|
+
classifyTurnMode,
|
|
8
|
+
contractStatusFromPhaseClass,
|
|
9
|
+
extractTaskContract,
|
|
10
|
+
isActionableTurn,
|
|
11
|
+
isRefactorObjective,
|
|
12
|
+
isSocialOrTrivial,
|
|
13
|
+
mergeFollowUpIntoContract,
|
|
14
|
+
renderContractProjection,
|
|
15
|
+
renderTaskAnchor
|
|
16
|
+
} from "./chunk-P6GJOVO6.js";
|
|
17
|
+
import "./chunk-TPI73L57.js";
|
|
18
|
+
import "./chunk-5GGOGLSN.js";
|
|
19
|
+
export {
|
|
20
|
+
advanceContractStatus,
|
|
21
|
+
classifyPlanMethodology,
|
|
22
|
+
classifyTaskDepth,
|
|
23
|
+
classifyTurnMode,
|
|
24
|
+
contractStatusFromPhaseClass,
|
|
25
|
+
extractTaskContract,
|
|
26
|
+
isActionableTurn,
|
|
27
|
+
isRefactorObjective,
|
|
28
|
+
isSocialOrTrivial,
|
|
29
|
+
mergeFollowUpIntoContract,
|
|
30
|
+
renderContractProjection,
|
|
31
|
+
renderTaskAnchor
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
createTaskLedger
|
|
5
|
+
} from "./chunk-2XN7PM4N.js";
|
|
6
|
+
import "./chunk-5GGOGLSN.js";
|
|
7
|
+
export {
|
|
8
|
+
createTaskLedger
|
|
9
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
TEAM_TIMEOUT_CEIL_MS,
|
|
5
|
+
collectAllDirtyRows,
|
|
6
|
+
collectBlockedAttribution,
|
|
7
|
+
createTeamOrchestrateTool,
|
|
8
|
+
formatTeamSummary,
|
|
9
|
+
teamOrchestrateTimeoutMs
|
|
10
|
+
} from "./chunk-D54ZWG4T.js";
|
|
11
|
+
import {
|
|
12
|
+
teamReviewChangedFiles,
|
|
13
|
+
teamReviewFocusHint,
|
|
14
|
+
teamReviewForceLevel
|
|
15
|
+
} from "./chunk-R43HJCDX.js";
|
|
16
|
+
import "./chunk-D4PTYFOG.js";
|
|
17
|
+
import "./chunk-AERM3VGP.js";
|
|
18
|
+
import "./chunk-RK3JHWPT.js";
|
|
19
|
+
import "./chunk-NH6VIOAR.js";
|
|
20
|
+
import "./chunk-S4K4L6IM.js";
|
|
21
|
+
import "./chunk-3VGD2FXB.js";
|
|
22
|
+
import "./chunk-UXNLELW6.js";
|
|
23
|
+
import "./chunk-TVHW77C7.js";
|
|
24
|
+
import "./chunk-EHHUASO5.js";
|
|
25
|
+
import "./chunk-LA6IPTGH.js";
|
|
26
|
+
import "./chunk-HBVF6BWO.js";
|
|
27
|
+
import "./chunk-UHGLFRZE.js";
|
|
28
|
+
import "./chunk-4QJ3Y5JM.js";
|
|
29
|
+
import "./chunk-CGOADM2X.js";
|
|
30
|
+
import "./chunk-ZMZCZNKU.js";
|
|
31
|
+
import "./chunk-7RDOV3DF.js";
|
|
32
|
+
import "./chunk-6HSVXHCZ.js";
|
|
33
|
+
import "./chunk-OHSV42QB.js";
|
|
34
|
+
import "./chunk-ADIVZ2D5.js";
|
|
35
|
+
import "./chunk-GD4ZNZ7W.js";
|
|
36
|
+
import "./chunk-Z5Z3JHJY.js";
|
|
37
|
+
import "./chunk-35H7GVNR.js";
|
|
38
|
+
import "./chunk-SUJERP5I.js";
|
|
39
|
+
import "./chunk-CI4R6P2B.js";
|
|
40
|
+
import "./chunk-XU2YXCDL.js";
|
|
41
|
+
import "./chunk-ETHFACAB.js";
|
|
42
|
+
import "./chunk-THKDVSEC.js";
|
|
43
|
+
import "./chunk-UFMN76QD.js";
|
|
44
|
+
import "./chunk-ER5JW2QZ.js";
|
|
45
|
+
import "./chunk-CGFZGR7G.js";
|
|
46
|
+
import "./chunk-P5KJURUR.js";
|
|
47
|
+
import "./chunk-WMUWEO2C.js";
|
|
48
|
+
import "./chunk-BKTQAYO2.js";
|
|
49
|
+
import "./chunk-OO3TAHO5.js";
|
|
50
|
+
import "./chunk-7KUCBNLB.js";
|
|
51
|
+
import "./chunk-A5MNH4ER.js";
|
|
52
|
+
import "./chunk-BCQXEZPJ.js";
|
|
53
|
+
import "./chunk-5GGOGLSN.js";
|
|
54
|
+
export {
|
|
55
|
+
TEAM_TIMEOUT_CEIL_MS,
|
|
56
|
+
collectAllDirtyRows,
|
|
57
|
+
collectBlockedAttribution,
|
|
58
|
+
createTeamOrchestrateTool,
|
|
59
|
+
formatTeamSummary,
|
|
60
|
+
teamOrchestrateTimeoutMs,
|
|
61
|
+
teamReviewChangedFiles,
|
|
62
|
+
teamReviewFocusHint,
|
|
63
|
+
teamReviewForceLevel
|
|
64
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-5GGOGLSN.js";
|
|
6
|
+
|
|
7
|
+
// src/agent/title-extract.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var MAX_INPUT_CHARS = 800;
|
|
10
|
+
var MAX_TITLE_CHARS = 40;
|
|
11
|
+
var TITLE_SYSTEM = `You generate a concise session title (<=40 chars) from the user's first message in a coding assistant session.
|
|
12
|
+
|
|
13
|
+
Rules:
|
|
14
|
+
- Output ONLY the title text. No quotes, no markdown, no explanation.
|
|
15
|
+
- <=40 characters. Truncate gracefully if the natural title would exceed it.
|
|
16
|
+
- Use the same language as the user's message (Chinese in \u2192 Chinese out, English in \u2192 English out).
|
|
17
|
+
- Imperative or noun phrase, not a full sentence ("\u52A0\u6392\u5E8F\u6309\u94AE" not "\u7528\u6237\u60F3\u8981\u52A0\u4E00\u4E2A\u6392\u5E8F\u6309\u94AE").
|
|
18
|
+
- Strip pleasantries ("\u5E2E\u6211", "\u8BF7", "\u80FD\u4E0D\u80FD", "can you") and meta talk ("\u8FD9\u4E2A\u4EFB\u52A1", "\u9700\u6C42\u662F").
|
|
19
|
+
- No trailing punctuation.`;
|
|
20
|
+
function buildTitleUser(firstMessage) {
|
|
21
|
+
const truncated = firstMessage.length > MAX_INPUT_CHARS ? firstMessage.slice(0, MAX_INPUT_CHARS) : firstMessage;
|
|
22
|
+
return `First message:
|
|
23
|
+
${truncated}
|
|
24
|
+
|
|
25
|
+
Generate a session title (<=40 chars, same language as the message).`;
|
|
26
|
+
}
|
|
27
|
+
function cleanTitle(raw) {
|
|
28
|
+
let t = raw.trim();
|
|
29
|
+
if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'") || t.startsWith("\u300C") && t.endsWith("\u300D") || t.startsWith("\u201C") && t.endsWith("\u201D")) {
|
|
30
|
+
t = t.slice(1, -1).trim();
|
|
31
|
+
}
|
|
32
|
+
t = t.replace(/^(title|标题)\s*[::]\s*/i, "");
|
|
33
|
+
t = t.replace(/\s+/g, " ").trim();
|
|
34
|
+
if (!t) return null;
|
|
35
|
+
if (t.length > MAX_TITLE_CHARS) t = t.slice(0, MAX_TITLE_CHARS).trim();
|
|
36
|
+
return t || null;
|
|
37
|
+
}
|
|
38
|
+
async function extractSessionTitle(firstMessage, complete, signal) {
|
|
39
|
+
try {
|
|
40
|
+
const raw = await complete(TITLE_SYSTEM, buildTitleUser(firstMessage), signal);
|
|
41
|
+
return cleanTitle(raw);
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
buildTitleUser,
|
|
48
|
+
cleanTitle,
|
|
49
|
+
extractSessionTitle
|
|
50
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
TODO_TOOL,
|
|
5
|
+
createTodoTool,
|
|
6
|
+
defaultStore,
|
|
7
|
+
getTodoRegressionStats,
|
|
8
|
+
getTodos,
|
|
9
|
+
loadTodos,
|
|
10
|
+
setTodoSession,
|
|
11
|
+
setTodos
|
|
12
|
+
} from "./chunk-AE3P3F6W.js";
|
|
13
|
+
import "./chunk-LH5VCGLB.js";
|
|
14
|
+
import "./chunk-6S5FPUS7.js";
|
|
15
|
+
import "./chunk-EXXICUIW.js";
|
|
16
|
+
import "./chunk-QARAGUXX.js";
|
|
17
|
+
import "./chunk-DEBI37QB.js";
|
|
18
|
+
import "./chunk-OO3TAHO5.js";
|
|
19
|
+
import "./chunk-A5MNH4ER.js";
|
|
20
|
+
import "./chunk-BCQXEZPJ.js";
|
|
21
|
+
import "./chunk-5GGOGLSN.js";
|
|
22
|
+
export {
|
|
23
|
+
TODO_TOOL,
|
|
24
|
+
createTodoTool,
|
|
25
|
+
defaultStore,
|
|
26
|
+
getTodoRegressionStats,
|
|
27
|
+
getTodos,
|
|
28
|
+
loadTodos,
|
|
29
|
+
setTodoSession,
|
|
30
|
+
setTodos
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
TODO_EMPTY_RESULT,
|
|
5
|
+
TodoStore
|
|
6
|
+
} from "./chunk-DEBI37QB.js";
|
|
7
|
+
import "./chunk-OO3TAHO5.js";
|
|
8
|
+
import "./chunk-5GGOGLSN.js";
|
|
9
|
+
export {
|
|
10
|
+
TODO_EMPTY_RESULT,
|
|
11
|
+
TodoStore
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__resetToolPresetForTest,
|
|
5
|
+
invalidateToolPreset,
|
|
6
|
+
presetIncludes,
|
|
7
|
+
resolveToolPreset
|
|
8
|
+
} from "./chunk-ER5JW2QZ.js";
|
|
9
|
+
import "./chunk-CGFZGR7G.js";
|
|
10
|
+
import "./chunk-P5KJURUR.js";
|
|
11
|
+
import "./chunk-WMUWEO2C.js";
|
|
12
|
+
import "./chunk-BKTQAYO2.js";
|
|
13
|
+
import "./chunk-OO3TAHO5.js";
|
|
14
|
+
import "./chunk-7KUCBNLB.js";
|
|
15
|
+
import "./chunk-A5MNH4ER.js";
|
|
16
|
+
import "./chunk-BCQXEZPJ.js";
|
|
17
|
+
import "./chunk-5GGOGLSN.js";
|
|
18
|
+
export {
|
|
19
|
+
__resetToolPresetForTest,
|
|
20
|
+
invalidateToolPreset,
|
|
21
|
+
presetIncludes,
|
|
22
|
+
resolveToolPreset
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ALL_KNOWN_TOOLS,
|
|
5
|
+
CORE_TOOLS,
|
|
6
|
+
EXTENDED_TOOLS,
|
|
7
|
+
gateToolDefinitions,
|
|
8
|
+
isCoreTool,
|
|
9
|
+
isExtendedTool,
|
|
10
|
+
resolveMainToolTier,
|
|
11
|
+
validateTierInvariant
|
|
12
|
+
} from "./chunk-JSXWIWWJ.js";
|
|
13
|
+
import "./chunk-5GGOGLSN.js";
|
|
14
|
+
export {
|
|
15
|
+
ALL_KNOWN_TOOLS,
|
|
16
|
+
CORE_TOOLS,
|
|
17
|
+
EXTENDED_TOOLS,
|
|
18
|
+
gateToolDefinitions,
|
|
19
|
+
isCoreTool,
|
|
20
|
+
isExtendedTool,
|
|
21
|
+
resolveMainToolTier,
|
|
22
|
+
validateTierInvariant
|
|
23
|
+
};
|