@mindstudio-ai/agent 0.1.176 → 0.1.177
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/CHANGELOG.md +7 -0
- package/dist/analytics/index.d.ts +384 -0
- package/dist/auth/index.d.ts +113 -0
- package/dist/browser/index.d.ts +332 -0
- package/dist/cli.js +27 -27
- package/dist/client.d.ts +767 -0
- package/dist/config.d.ts +13 -0
- package/dist/context.d.ts +125 -0
- package/dist/datasources/index.d.ts +52 -0
- package/dist/datasources/source.d.ts +1074 -0
- package/dist/db/aggregate.d.ts +101 -0
- package/dist/db/index.d.ts +280 -0
- package/dist/db/mutation.d.ts +65 -0
- package/dist/db/predicate.d.ts +85 -0
- package/dist/db/query.d.ts +233 -0
- package/dist/db/raw.d.ts +36 -0
- package/dist/db/readBatching.d.ts +36 -0
- package/dist/db/scanHints.d.ts +8 -0
- package/dist/db/sql.d.ts +136 -0
- package/dist/db/table.d.ts +146 -0
- package/dist/db/time.d.ts +17 -0
- package/dist/db/types.d.ts +237 -0
- package/dist/db-ws.d.ts +35 -0
- package/dist/email/index.d.ts +396 -0
- package/dist/errors.d.ts +34 -0
- package/dist/events/index.d.ts +127 -0
- package/dist/files/index.d.ts +62 -0
- package/dist/files/store.d.ts +244 -0
- package/dist/generated/metadata.d.ts +8 -0
- package/dist/generated/snippets.d.ts +8 -0
- package/dist/generated/steps.d.ts +2745 -0
- package/dist/generated/types.d.ts +4234 -0
- package/dist/http.d.ts +22 -0
- package/dist/index.d.ts +59 -13329
- package/dist/index.js +15 -15
- package/dist/index.js.map +7 -1
- package/dist/jewel/index.d.ts +325 -0
- package/dist/mapper/index.d.ts +229 -0
- package/dist/rate-limit.d.ts +25 -0
- package/dist/reader/index.d.ts +170 -0
- package/dist/respond.d.ts +68 -0
- package/dist/task/index.d.ts +18 -0
- package/dist/task/local.d.ts +48 -0
- package/dist/task/schema.d.ts +120 -0
- package/dist/task/types.d.ts +203 -0
- package/dist/types.d.ts +591 -0
- package/dist/voice/index.d.ts +87 -0
- package/package.json +6 -12
- package/dist/postinstall.js +0 -12115
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface MindStudioConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
/** @internal Last update check metadata. */
|
|
5
|
+
_updateCheck?: {
|
|
6
|
+
latestVersion: string;
|
|
7
|
+
checkedAt: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function getConfigPath(): string;
|
|
11
|
+
export declare function loadConfig(): MindStudioConfig;
|
|
12
|
+
export declare function saveConfig(config: MindStudioConfig): void;
|
|
13
|
+
export declare function clearConfig(): void;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncLocalStorage-based request context for concurrent execution.
|
|
3
|
+
*
|
|
4
|
+
* When the sandbox wraps each handler call in `runWithContext()`, all SDK
|
|
5
|
+
* reads (auth, db, callback token, base URL) pull from the request-scoped
|
|
6
|
+
* store instead of process globals. This enables concurrent request
|
|
7
|
+
* processing on persistent sandbox workers without identity leakage.
|
|
8
|
+
*
|
|
9
|
+
* Fully backwards compatible — when no ALS store is active, all getters
|
|
10
|
+
* fall back to the existing global/env-based behavior.
|
|
11
|
+
*/
|
|
12
|
+
import type { AppAuthContext, AppDatabase, AuthTableConfig } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Originating-session identity for method invocations triggered by a
|
|
15
|
+
* conversational surface (a voice call's tool use, an agent-chat tool use).
|
|
16
|
+
* Platform-resolved and guaranteed — never model- or client-supplied — so a
|
|
17
|
+
* method can deterministically correlate back to the exact client session
|
|
18
|
+
* that triggered it, including anonymous sessions (via `visitorId`).
|
|
19
|
+
* Channel-discriminated so future surfaces extend without breaking.
|
|
20
|
+
*/
|
|
21
|
+
export interface SessionContext {
|
|
22
|
+
/**
|
|
23
|
+
* Which surface invoked this method: `voice`/`agent` for conversational
|
|
24
|
+
* tool calls (which carry their session/thread ids below), `web` for a
|
|
25
|
+
* browser interface-session method call, `api` for an app-key or
|
|
26
|
+
* platform-key call. `web`/`api` carry only `visitorId`. Absent on a run
|
|
27
|
+
* no caller started (cron, inbound email, a webhook) and on older platform
|
|
28
|
+
* versions.
|
|
29
|
+
*/
|
|
30
|
+
channel?: 'voice' | 'agent' | 'web' | 'api';
|
|
31
|
+
/**
|
|
32
|
+
* The host the request was served on: `example.com`, the app's
|
|
33
|
+
* `<slug>.madewithremy.com`, a branch preview's host. Under another app's
|
|
34
|
+
* mount it is that app's host, the site the visitor is on. Platform-resolved
|
|
35
|
+
* from the host the request arrived at, so one app serving several sites can
|
|
36
|
+
* key on it. Absent when the run came through no app host: cron, inbound
|
|
37
|
+
* email, voice and task-agent tool calls, background runs, and dev.
|
|
38
|
+
*/
|
|
39
|
+
host?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Which world the run is in: `live` (the deployed app), `preview` (a branch
|
|
42
|
+
* preview, on its own copy of the data) or `dev` (the editor's dev box,
|
|
43
|
+
* whose file stores are live's). Present on every run on current platform
|
|
44
|
+
* versions; use it to keep a dev run's fixed-key writes off what live reads.
|
|
45
|
+
*/
|
|
46
|
+
environment?: 'live' | 'preview' | 'dev';
|
|
47
|
+
/** Voice-session id — matches the browser voice client's `session.sessionId`. */
|
|
48
|
+
voiceSessionId?: string;
|
|
49
|
+
/** Agent-chat thread id. */
|
|
50
|
+
threadId?: string;
|
|
51
|
+
/** Stable visitor key — present for anonymous AND signed-in sessions. */
|
|
52
|
+
visitorId?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Voice transport: a browser session (`web`) or a phone call, by direction.
|
|
55
|
+
* Use it to branch behavior that assumes a screen — on a phone call there
|
|
56
|
+
* is none, so describe everything in speech. Absent for agent-chat sessions
|
|
57
|
+
* and on older platform versions — treat absent as `web`.
|
|
58
|
+
*/
|
|
59
|
+
medium?: 'web' | 'phone-in' | 'phone-out';
|
|
60
|
+
/**
|
|
61
|
+
* Phone sessions only: the call's numbers (`fromNumber` = who initiated,
|
|
62
|
+
* `to` = who was dialed, in both directions; `appNumber` = the app's own
|
|
63
|
+
* number on the call, the dialed one inbound and the caller ID outbound,
|
|
64
|
+
* which is the key for an app that gives each of its tenants a number).
|
|
65
|
+
* Context and routing only — caller ID is trivially spoofable, so never
|
|
66
|
+
* treat it as identity: don't gate roles on it or speak account specifics
|
|
67
|
+
* to an unverified caller. In-call verification is the auth rail.
|
|
68
|
+
* `appNumber` is absent on older platform versions.
|
|
69
|
+
*/
|
|
70
|
+
sip?: {
|
|
71
|
+
to: string;
|
|
72
|
+
fromNumber: string;
|
|
73
|
+
appNumber?: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Per-request context provided by the sandbox execution service.
|
|
78
|
+
* Contains everything the SDK needs to resolve auth, databases, and
|
|
79
|
+
* API endpoints for a specific request.
|
|
80
|
+
*/
|
|
81
|
+
export interface RequestContext {
|
|
82
|
+
/** Hook/callback token for this request's auth. */
|
|
83
|
+
callbackToken: string;
|
|
84
|
+
/** API base URL for this request (e.g. from REMOTE_HOSTNAME). */
|
|
85
|
+
remoteHostname?: string;
|
|
86
|
+
/** Auth context: userId + role assignments for this request's user. */
|
|
87
|
+
auth?: AppAuthContext;
|
|
88
|
+
/** Database metadata for this request's app. */
|
|
89
|
+
databases?: AppDatabase[];
|
|
90
|
+
/** Auth table config (managed columns) for this request's app. */
|
|
91
|
+
authConfig?: AuthTableConfig;
|
|
92
|
+
/** Stream ID for SSE streaming in this request. */
|
|
93
|
+
streamId?: string;
|
|
94
|
+
/** Originating-session identity (voice/agent tool calls); absent otherwise. */
|
|
95
|
+
session?: SessionContext;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the current request context from AsyncLocalStorage, if any.
|
|
99
|
+
* Returns undefined when not running inside `runWithContext()`.
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
export declare function getRequestContext(): RequestContext | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Run an async function with a scoped request context. Inside `fn`, all
|
|
105
|
+
* SDK reads (auth, db, callback token, base URL) pull from `ctx` instead
|
|
106
|
+
* of process globals.
|
|
107
|
+
*
|
|
108
|
+
* This enables concurrent request processing — multiple `runWithContext()`
|
|
109
|
+
* calls can execute in parallel without identity leakage.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { runWithContext } from '@mindstudio-ai/agent';
|
|
114
|
+
*
|
|
115
|
+
* await runWithContext({
|
|
116
|
+
* callbackToken: req.callbackToken,
|
|
117
|
+
* auth: req.auth,
|
|
118
|
+
* databases: req.databases,
|
|
119
|
+
* }, async () => {
|
|
120
|
+
* // auth.userId returns this request's user, not the global one
|
|
121
|
+
* const user = await Users.get(auth.userId);
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function runWithContext<T>(ctx: RequestContext, fn: () => T | Promise<T>): T | Promise<T>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `dataSources` namespace — searchable document corpora for MindStudio
|
|
3
|
+
* apps. The retrieval half of the platform's managed data layer, shaped like
|
|
4
|
+
* `db` and `files`: declare a source at module scope, import the handle into
|
|
5
|
+
* route handlers.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // datasources/policies.ts
|
|
9
|
+
* import { dataSources } from '@mindstudio-ai/agent';
|
|
10
|
+
* export const Policies = dataSources.defineDataSource('policies');
|
|
11
|
+
*
|
|
12
|
+
* // routes/ask.ts
|
|
13
|
+
* import { Policies } from '../datasources/policies';
|
|
14
|
+
*
|
|
15
|
+
* const { results } = await Policies.search('what are the payment terms?');
|
|
16
|
+
* const context = results.map((r) => r.text).join('\n\n');
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The platform owns parsing, chunking, embedding, storage and isolation. You
|
|
20
|
+
* declare what the corpus is and search it; every hit comes back with a
|
|
21
|
+
* citation pointing at the source document.
|
|
22
|
+
*
|
|
23
|
+
* **Corpora are usually built at development time**, not through your app's
|
|
24
|
+
* UI — the agent adds documents while building, and the app is a consumer.
|
|
25
|
+
* `add()` exists for apps where users upload documents themselves.
|
|
26
|
+
*
|
|
27
|
+
* **A data source is live and shared.** Unlike database tables there is no dev
|
|
28
|
+
* copy and no per-release isolation: adding or removing a document affects
|
|
29
|
+
* what the deployed app retrieves, immediately. Scenarios never reset a data
|
|
30
|
+
* source, and re-ingesting a large corpus costs real money.
|
|
31
|
+
*/
|
|
32
|
+
import { DataSource, type DataSourcesTransport } from './source.js';
|
|
33
|
+
export { DataSource } from './source.js';
|
|
34
|
+
export type { AddOptions, AddResult, BranchPosition, Citation, DataSourceChunk, DataSourceDocument, DataSourceJob, DataSourceJobPlan, DataSourceJobState, DataSourcePassage, DataSourcePassagePage, DataSourceStats, DictionaryEntry, DictionaryPushResult, DictionaryRelink, DictionaryReport, DocumentMetadata, DocumentSelector, MetadataRange, MetadataValue, SearchExplain, SearchFilter, SearchHit, SearchMode, SearchOptions, SearchRan, } from './source.js';
|
|
35
|
+
/** The `dataSources` namespace object. */
|
|
36
|
+
export interface DataSources {
|
|
37
|
+
/**
|
|
38
|
+
* Define a data source. Lazy — nothing executes until you await a method on
|
|
39
|
+
* the returned {@link DataSource}, so it's safe to call at module scope.
|
|
40
|
+
*
|
|
41
|
+
* The source is created on first use if it doesn't exist, so naming one the
|
|
42
|
+
* build hasn't populated yet is not an error; it just searches empty.
|
|
43
|
+
*/
|
|
44
|
+
defineDataSource(name: string): DataSource;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a DataSources namespace bound to a transport.
|
|
48
|
+
*
|
|
49
|
+
* @internal Called by MindStudioAgent; not part of the public API — access
|
|
50
|
+
* `dataSources` via the agent instance or the top-level export.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createDataSources(call: DataSourcesTransport): DataSources;
|