dsh-supermemory 0.1.1 → 0.1.2
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/lib/index.d.mts +10 -1
- package/lib/index.mjs +71 -25
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -178,6 +178,15 @@ declare function promptFrom(messages: readonly UserMessage[]): string;
|
|
|
178
178
|
declare function readOnlyToolOf(toolName: string, serverName: string): string | null;
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/status.d.ts
|
|
181
|
+
/**
|
|
182
|
+
* dsh-tui renders a host command's result as a one-line toast: it strips ANSI,
|
|
183
|
+
* collapses newlines to spaces, and truncates at 200 cells. Every report here
|
|
184
|
+
* therefore leads with a summary that fits, and puts the field-per-line detail
|
|
185
|
+
* after it for clients that render newlines.
|
|
186
|
+
*/
|
|
187
|
+
declare const TOAST_CELLS = 200;
|
|
188
|
+
/** Join summary fields the way the toast will show them. */
|
|
189
|
+
declare function summaryLine(fields: readonly string[]): string;
|
|
181
190
|
/** Never print a full key: at most the first 6 and last 4 characters. */
|
|
182
191
|
declare function maskKey(key: string): string;
|
|
183
192
|
//#endregion
|
|
@@ -197,4 +206,4 @@ declare function splitFrontmatter(source: string): {
|
|
|
197
206
|
declare const name = "supermemory";
|
|
198
207
|
declare function apply(ctx: Context, config: PluginConfig): void;
|
|
199
208
|
//#endregion
|
|
200
|
-
export { PluginConfig as Config, PluginConfig, PLUGIN_SOURCE, SupermemoryRuntime, TranscriptBlock, TranscriptDelta, TranscriptEntry, TranscriptEvent, TranscriptSession, TranscriptTurn, apply, cleanContent, createRuntime, cwdOf, entriesFromEvents, findSignalTurnIndices, formatContext, formatEntry, formatNewEntries, formatRecall, formatSignalEntries, formatToolInputCompact, getLastCapturedSeq, getTextFromEntry, getTurnsAroundSignals, groupEntriesIntoTurns, hashText, isSubagent, maskKey, name, promptFrom, readOnlyToolOf, resolveSkillDir, resultText, sessionIdOf, setLastCapturedSeq, shouldSkip, splitFrontmatter, truncate };
|
|
209
|
+
export { PluginConfig as Config, PluginConfig, PLUGIN_SOURCE, SupermemoryRuntime, TOAST_CELLS, TranscriptBlock, TranscriptDelta, TranscriptEntry, TranscriptEvent, TranscriptSession, TranscriptTurn, apply, cleanContent, createRuntime, cwdOf, entriesFromEvents, findSignalTurnIndices, formatContext, formatEntry, formatNewEntries, formatRecall, formatSignalEntries, formatToolInputCompact, getLastCapturedSeq, getTextFromEntry, getTurnsAroundSignals, groupEntriesIntoTurns, hashText, isSubagent, maskKey, name, promptFrom, readOnlyToolOf, resolveSkillDir, resultText, sessionIdOf, setLastCapturedSeq, shouldSkip, splitFrontmatter, summaryLine, truncate };
|
package/lib/index.mjs
CHANGED
|
@@ -1147,6 +1147,17 @@ function registerSessionStart(ctx, rt, config) {
|
|
|
1147
1147
|
//#endregion
|
|
1148
1148
|
//#region src/status.ts
|
|
1149
1149
|
const PROBE_TIMEOUT_MS = 8e3;
|
|
1150
|
+
/**
|
|
1151
|
+
* dsh-tui renders a host command's result as a one-line toast: it strips ANSI,
|
|
1152
|
+
* collapses newlines to spaces, and truncates at 200 cells. Every report here
|
|
1153
|
+
* therefore leads with a summary that fits, and puts the field-per-line detail
|
|
1154
|
+
* after it for clients that render newlines.
|
|
1155
|
+
*/
|
|
1156
|
+
const TOAST_CELLS = 200;
|
|
1157
|
+
/** Join summary fields the way the toast will show them. */
|
|
1158
|
+
function summaryLine(fields) {
|
|
1159
|
+
return `◪ supermemory · ${fields.filter(Boolean).join(" · ")}`;
|
|
1160
|
+
}
|
|
1150
1161
|
/** Never print a full key: at most the first 6 and last 4 characters. */
|
|
1151
1162
|
function maskKey(key) {
|
|
1152
1163
|
if (key.length <= 10) return `${key.slice(0, 2)}…`;
|
|
@@ -1155,17 +1166,20 @@ function maskKey(key) {
|
|
|
1155
1166
|
function resolveKey(cwd) {
|
|
1156
1167
|
if (process.env.SUPERMEMORY_CC_API_KEY) return {
|
|
1157
1168
|
key: process.env.SUPERMEMORY_CC_API_KEY,
|
|
1158
|
-
source: "env SUPERMEMORY_CC_API_KEY"
|
|
1169
|
+
source: "env SUPERMEMORY_CC_API_KEY",
|
|
1170
|
+
shortSource: "env"
|
|
1159
1171
|
};
|
|
1160
1172
|
const projectConfig = loadProjectConfig(cwd);
|
|
1161
1173
|
if (projectConfig?.apiKey) return {
|
|
1162
1174
|
key: projectConfig.apiKey,
|
|
1163
|
-
source: ".claude/.supermemory-claude/config.json"
|
|
1175
|
+
source: ".claude/.supermemory-claude/config.json",
|
|
1176
|
+
shortSource: "project config"
|
|
1164
1177
|
};
|
|
1165
1178
|
const credentials = loadCredentials();
|
|
1166
1179
|
if (credentials?.apiKey) return {
|
|
1167
1180
|
key: credentials.apiKey,
|
|
1168
|
-
source: CREDENTIALS_FILE
|
|
1181
|
+
source: CREDENTIALS_FILE,
|
|
1182
|
+
shortSource: "credentials.json"
|
|
1169
1183
|
};
|
|
1170
1184
|
return null;
|
|
1171
1185
|
}
|
|
@@ -1189,13 +1203,28 @@ async function probe(baseUrl, key, containerTag) {
|
|
|
1189
1203
|
}),
|
|
1190
1204
|
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
|
|
1191
1205
|
});
|
|
1192
|
-
if (response.status === 200) return
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1206
|
+
if (response.status === 200) return {
|
|
1207
|
+
short: "api 200",
|
|
1208
|
+
detail: "reachable — 200, the key works"
|
|
1209
|
+
};
|
|
1210
|
+
if (response.status === 401 || response.status === 403) return {
|
|
1211
|
+
short: `api ${response.status} KEY REVOKED`,
|
|
1212
|
+
detail: `reachable, but the key is invalid or revoked — ${response.status}. Re-authenticate at ${AUTH_BASE_URL}`
|
|
1213
|
+
};
|
|
1214
|
+
if (response.status >= 500) return {
|
|
1215
|
+
short: `api ${response.status}`,
|
|
1216
|
+
detail: `API error — ${response.status}, service temporarily unavailable`
|
|
1217
|
+
};
|
|
1218
|
+
return {
|
|
1219
|
+
short: `api ${response.status}`,
|
|
1220
|
+
detail: `unexpected response — ${response.status}`
|
|
1221
|
+
};
|
|
1196
1222
|
} catch (err) {
|
|
1197
1223
|
const error = err;
|
|
1198
|
-
return
|
|
1224
|
+
return {
|
|
1225
|
+
short: "api UNREACHABLE",
|
|
1226
|
+
detail: `UNREACHABLE — ${error.name === "TimeoutError" ? `timed out after ${PROBE_TIMEOUT_MS}ms` : error.message}`
|
|
1227
|
+
};
|
|
1199
1228
|
}
|
|
1200
1229
|
}
|
|
1201
1230
|
function registerStatusCommand(ctx, config) {
|
|
@@ -1211,25 +1240,42 @@ function registerStatusCommand(ctx, config) {
|
|
|
1211
1240
|
const resolved = resolveKey(cwd);
|
|
1212
1241
|
const prefix = `mcp__${config.mcpServerName ?? "supermemory"}__`;
|
|
1213
1242
|
const mcpTools = (ctx.get("tools")?.schemas(agent.id) ?? []).map((schema) => schema.name).filter((name) => name.startsWith(prefix));
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
"",
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1243
|
+
const mcpShort = mcpTools.length > 0 ? `mcp ${mcpTools.length} tools` : "mcp NONE";
|
|
1244
|
+
if (!resolved) return {
|
|
1245
|
+
kind: "success",
|
|
1246
|
+
text: [
|
|
1247
|
+
summaryLine([
|
|
1248
|
+
"NOT authenticated",
|
|
1249
|
+
"set SUPERMEMORY_CC_API_KEY or start a new session to log in",
|
|
1250
|
+
projectName
|
|
1251
|
+
]),
|
|
1252
|
+
"",
|
|
1253
|
+
`container tag ${containerTag}`,
|
|
1254
|
+
`settings ${SETTINGS_FILE}`,
|
|
1255
|
+
`login page ${AUTH_BASE_URL}`
|
|
1256
|
+
].join("\n")
|
|
1257
|
+
};
|
|
1228
1258
|
const baseUrl = getBaseUrl(cwd);
|
|
1229
|
-
|
|
1259
|
+
const probed = await probe(baseUrl, resolved.key, containerTag);
|
|
1230
1260
|
return {
|
|
1231
1261
|
kind: "success",
|
|
1232
|
-
text:
|
|
1262
|
+
text: [
|
|
1263
|
+
summaryLine([
|
|
1264
|
+
`auth ok (${resolved.shortSource})`,
|
|
1265
|
+
probed.short,
|
|
1266
|
+
mcpShort,
|
|
1267
|
+
containerTag
|
|
1268
|
+
]),
|
|
1269
|
+
"",
|
|
1270
|
+
`project ${projectName}`,
|
|
1271
|
+
`container tag ${containerTag}`,
|
|
1272
|
+
`authenticated yes`,
|
|
1273
|
+
`key ${maskKey(resolved.key)} (from ${resolved.source})`,
|
|
1274
|
+
`api ${baseUrl}`,
|
|
1275
|
+
`api probe ${probed.detail}`,
|
|
1276
|
+
`mcp ${mcpTools.length > 0 ? `${mcpTools.length} tool${mcpTools.length === 1 ? "" : "s"} under ${prefix}` : `no ${prefix}* tools registered`}`,
|
|
1277
|
+
`settings ${SETTINGS_FILE}`
|
|
1278
|
+
].join("\n")
|
|
1233
1279
|
};
|
|
1234
1280
|
}
|
|
1235
1281
|
});
|
|
@@ -1279,4 +1325,4 @@ function apply(ctx, config) {
|
|
|
1279
1325
|
});
|
|
1280
1326
|
}
|
|
1281
1327
|
//#endregion
|
|
1282
|
-
export { PluginConfig as Config, PluginConfig, PLUGIN_SOURCE, apply, cleanContent, createRuntime, cwdOf, entriesFromEvents, findSignalTurnIndices, formatContext, formatEntry, formatNewEntries, formatRecall, formatSignalEntries, formatToolInputCompact, getLastCapturedSeq, getTextFromEntry, getTurnsAroundSignals, groupEntriesIntoTurns, hashText, isSubagent, maskKey, name, promptFrom, readOnlyToolOf, resolveSkillDir, resultText, sessionIdOf, setLastCapturedSeq, shouldSkip, splitFrontmatter, truncate };
|
|
1328
|
+
export { PluginConfig as Config, PluginConfig, PLUGIN_SOURCE, TOAST_CELLS, apply, cleanContent, createRuntime, cwdOf, entriesFromEvents, findSignalTurnIndices, formatContext, formatEntry, formatNewEntries, formatRecall, formatSignalEntries, formatToolInputCompact, getLastCapturedSeq, getTextFromEntry, getTurnsAroundSignals, groupEntriesIntoTurns, hashText, isSubagent, maskKey, name, promptFrom, readOnlyToolOf, resolveSkillDir, resultText, sessionIdOf, setLastCapturedSeq, shouldSkip, splitFrontmatter, summaryLine, truncate };
|
package/package.json
CHANGED