@dbx-tools/appkit-mastra 0.1.112 → 0.3.1
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/README.md +309 -344
- package/index.ts +46 -0
- package/package.json +50 -28
- package/src/agents.ts +858 -0
- package/src/chart.ts +695 -0
- package/src/config.ts +443 -0
- package/src/filesystems.ts +1090 -0
- package/src/genie.ts +1091 -0
- package/src/history.ts +297 -0
- package/src/mcp.ts +105 -0
- package/src/memory.ts +300 -0
- package/src/mlflow.ts +149 -0
- package/src/model.ts +163 -0
- package/src/observability.ts +144 -0
- package/src/pagination.ts +34 -0
- package/src/plugin.ts +804 -0
- package/src/processors.ts +168 -0
- package/src/rest.ts +67 -0
- package/src/server.ts +343 -0
- package/src/serving-sanitize.ts +167 -0
- package/src/serving.ts +97 -0
- package/src/statement.ts +89 -0
- package/src/storage-schema.ts +41 -0
- package/src/summarize.ts +176 -0
- package/src/threads.ts +338 -0
- package/src/workspaces.ts +346 -0
- package/src/writer.ts +44 -0
- package/tsconfig.json +41 -0
- package/dist/index.d.ts +0 -1676
- package/dist/index.js +0 -5337
package/src/writer.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper for publishing events through Mastra's
|
|
3
|
+
* `ctx.writer`. Centralizes the "the downstream stream may already
|
|
4
|
+
* be closed, don't take the whole tool down" pattern that the
|
|
5
|
+
* Genie agent and chart tool both need.
|
|
6
|
+
*
|
|
7
|
+
* Failures are logged at `warn` (a persistently-closed writer is
|
|
8
|
+
* the most likely culprit when events go missing client-side) but
|
|
9
|
+
* swallowed so a cancelled request or a client that navigated
|
|
10
|
+
* away can't crash a tool mid-flight.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { MastraWriter } from "@dbx-tools/shared-mastra";
|
|
14
|
+
import { error, log } from "@dbx-tools/shared-core";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Best-effort `writer.write`. No-op when `writer` is undefined;
|
|
18
|
+
* caught errors are logged via `log.warn("writer:error", ...)`
|
|
19
|
+
* along with any caller-supplied `context` fields (e.g. a
|
|
20
|
+
* `chartId` or `messageId`) so the warning is greppable per
|
|
21
|
+
* resource.
|
|
22
|
+
*
|
|
23
|
+
* Returns when the write resolves or rejects; never throws.
|
|
24
|
+
*/
|
|
25
|
+
export async function safeWrite(
|
|
26
|
+
log: log.Logger,
|
|
27
|
+
writer: MastraWriter | undefined,
|
|
28
|
+
chunk: unknown,
|
|
29
|
+
context: Record<string, unknown> = {},
|
|
30
|
+
): Promise<void> {
|
|
31
|
+
if (!writer) {
|
|
32
|
+
log.debug("writer:no-writer", context);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await writer.write(chunk);
|
|
37
|
+
log.debug("writer:ok", context);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
log.warn("writer:error", {
|
|
40
|
+
...context,
|
|
41
|
+
error: error.errorMessage(err),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
|
|
2
|
+
{
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "lib",
|
|
6
|
+
"alwaysStrict": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"inlineSourceMap": true,
|
|
11
|
+
"inlineSources": true,
|
|
12
|
+
"lib": [
|
|
13
|
+
"ES2022"
|
|
14
|
+
],
|
|
15
|
+
"module": "ESNext",
|
|
16
|
+
"noEmitOnError": false,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"noImplicitAny": true,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noImplicitThis": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
"resolveJsonModule": true,
|
|
24
|
+
"strict": true,
|
|
25
|
+
"strictNullChecks": true,
|
|
26
|
+
"strictPropertyInitialization": true,
|
|
27
|
+
"stripInternal": true,
|
|
28
|
+
"target": "ES2022",
|
|
29
|
+
"types": [
|
|
30
|
+
"node"
|
|
31
|
+
],
|
|
32
|
+
"moduleResolution": "bundler",
|
|
33
|
+
"skipLibCheck": true
|
|
34
|
+
},
|
|
35
|
+
"include": [
|
|
36
|
+
"src/**/*.ts"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"node_modules"
|
|
40
|
+
]
|
|
41
|
+
}
|