@granular-software/sdk 0.2.1 → 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/dist/adapters/anthropic.d.mts +1 -1
- package/dist/adapters/anthropic.d.ts +1 -1
- package/dist/adapters/langchain.d.mts +1 -1
- package/dist/adapters/langchain.d.ts +1 -1
- package/dist/adapters/mastra.d.mts +1 -1
- package/dist/adapters/mastra.d.ts +1 -1
- package/dist/adapters/openai.d.mts +1 -1
- package/dist/adapters/openai.d.ts +1 -1
- package/dist/cli/index.js +6 -14
- package/dist/index.d.mts +53 -18
- package/dist/index.d.ts +53 -18
- package/dist/index.js +3988 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3988 -27
- package/dist/index.mjs.map +1 -1
- package/dist/{types-DiMEb3SE.d.mts → types-CnX4jXYQ.d.mts} +7 -3
- package/dist/{types-DiMEb3SE.d.ts → types-CnX4jXYQ.d.ts} +7 -3
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -7249,24 +7249,16 @@ function logEffect(name: string, className: string | null, id: string | null, pa
|
|
|
7249
7249
|
}
|
|
7250
7250
|
|
|
7251
7251
|
async function main() {
|
|
7252
|
-
const
|
|
7253
|
-
if (!
|
|
7254
|
-
console.error('[Effects] GRANULAR_API_KEY
|
|
7252
|
+
const auth = process.env.GRANULAR_TOKEN ?? process.env.GRANULAR_API_KEY;
|
|
7253
|
+
if (!auth) {
|
|
7254
|
+
console.error('[Effects] Set GRANULAR_API_KEY or GRANULAR_TOKEN (e.g. from simulator "Copy CLI env").');
|
|
7255
7255
|
process.exit(1);
|
|
7256
7256
|
}
|
|
7257
7257
|
|
|
7258
|
-
let WebSocketCtor: any;
|
|
7259
|
-
try {
|
|
7260
|
-
WebSocketCtor = (await import('ws')).default;
|
|
7261
|
-
} catch {
|
|
7262
|
-
log('Optional: install "ws" for Node.js WebSocket support. Using global WebSocket.');
|
|
7263
|
-
}
|
|
7264
|
-
|
|
7265
7258
|
log('Initializing client...');
|
|
7266
7259
|
const granular = new Granular({
|
|
7267
|
-
apiKey,
|
|
7268
|
-
apiUrl: API_URL,
|
|
7269
|
-
...(WebSocketCtor && { WebSocketCtor }),
|
|
7260
|
+
...(auth.startsWith('eyJ') ? { token: auth } : { apiKey: auth }),
|
|
7261
|
+
apiUrl: process.env.GRANULAR_API_URL ?? API_URL,
|
|
7270
7262
|
});
|
|
7271
7263
|
|
|
7272
7264
|
const userId = 'effects_user';
|
|
@@ -8049,7 +8041,7 @@ ${manifest.description}`);
|
|
|
8049
8041
|
lines.push(`import { Granular } from '@granular-software/sdk';`);
|
|
8050
8042
|
lines.push(`
|
|
8051
8043
|
const granular = new Granular({`);
|
|
8052
|
-
lines.push(` apiKey: process.env.GRANULAR_API_KEY
|
|
8044
|
+
lines.push(` ...(process.env.GRANULAR_TOKEN ? { token: process.env.GRANULAR_TOKEN } : { apiKey: process.env.GRANULAR_API_KEY! }),`);
|
|
8053
8045
|
lines.push(`});`);
|
|
8054
8046
|
lines.push(`
|
|
8055
8047
|
// 1. Record the user (creates or updates identity)`);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Automerge from '@automerge/automerge';
|
|
2
|
-
import { W as WSClientOptions, T as ToolWithHandler, P as PublishToolsResult, J as Job, a as ToolHandler, I as InstanceToolHandler, b as ToolInfo, c as ToolsChangedEvent, D as DomainState, G as GranularOptions, R as RecordUserOptions, U as User, C as ConnectOptions, E as EnvironmentData, d as GraphQLResult, e as DefineRelationshipOptions, f as RelationshipInfo, M as ModelRef, g as ManifestContent, h as RecordObjectOptions, i as RecordObjectResult, S as SandboxListResponse, j as Sandbox, k as CreateSandboxData, l as DeleteResponse, m as PermissionProfile, n as CreatePermissionProfileData, o as CreateEnvironmentData, p as Subject, A as AssignmentListResponse } from './types-
|
|
3
|
-
export {
|
|
2
|
+
import { W as WSClientOptions, T as ToolWithHandler, P as PublishToolsResult, J as Job, a as ToolHandler, I as InstanceToolHandler, b as ToolInfo, c as ToolsChangedEvent, D as DomainState, G as GranularOptions, R as RecordUserOptions, U as User, C as ConnectOptions, E as EnvironmentData, d as GraphQLResult, e as DefineRelationshipOptions, f as RelationshipInfo, M as ModelRef, g as ManifestContent, h as RecordObjectOptions, i as RecordObjectResult, S as SandboxListResponse, j as Sandbox, k as CreateSandboxData, l as DeleteResponse, m as PermissionProfile, n as CreatePermissionProfileData, o as CreateEnvironmentData, p as Subject, A as AssignmentListResponse } from './types-CnX4jXYQ.mjs';
|
|
3
|
+
export { a2 as APIError, u as Assignment, z as Build, F as BuildListResponse, B as BuildPolicy, y as BuildStatus, v as EnvironmentListResponse, r as GranularAuth, H as JobStatus, K as JobSubmitResult, w as Manifest, a0 as ManifestImport, x as ManifestListResponse, $ as ManifestOperation, Z as ManifestPropertySpec, _ as ManifestRelationshipDef, a1 as ManifestVolume, t as PermissionProfileListResponse, s as PermissionRules, L as Prompt, N as RPCRequest, V as RPCRequestFromServer, O as RPCResponse, Q as SyncMessage, X as ToolInvokeParams, Y as ToolResultParams, q as ToolSchema } from './types-CnX4jXYQ.mjs';
|
|
4
4
|
import { Doc } from '@automerge/automerge/slim';
|
|
5
5
|
|
|
6
6
|
declare class WSClient {
|
|
@@ -107,6 +107,10 @@ declare class Session {
|
|
|
107
107
|
ok: boolean;
|
|
108
108
|
environmentId?: string;
|
|
109
109
|
docId?: string;
|
|
110
|
+
graphContainerStatus?: {
|
|
111
|
+
lastKeepAliveAt: number;
|
|
112
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
113
|
+
};
|
|
110
114
|
}>;
|
|
111
115
|
/**
|
|
112
116
|
* Publish tools to the sandbox and register handlers for reverse-RPC.
|
|
@@ -245,21 +249,19 @@ declare class Session {
|
|
|
245
249
|
*/
|
|
246
250
|
getDomain(): Promise<DomainState>;
|
|
247
251
|
/**
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
* Falls back to generating markdown docs from the domain summary if
|
|
262
|
-
* the synthesis server is unavailable.
|
|
252
|
+
* Fetch a domain package part from the backend (no fallback).
|
|
253
|
+
*/
|
|
254
|
+
private fetchDomainPart;
|
|
255
|
+
/**
|
|
256
|
+
* Get TypeScript class declarations for the current domain (for LLM/code gen).
|
|
257
|
+
*/
|
|
258
|
+
getDomainTypes(): Promise<string>;
|
|
259
|
+
/**
|
|
260
|
+
* Get Markdown documentation for the current domain (human-readable).
|
|
261
|
+
*/
|
|
262
|
+
getDomainDocs(): Promise<string>;
|
|
263
|
+
/**
|
|
264
|
+
* Get domain documentation for LLMs. Returns types (preferred) or fallback.
|
|
263
265
|
*/
|
|
264
266
|
getDomainDocumentation(): Promise<string>;
|
|
265
267
|
/**
|
|
@@ -281,7 +283,7 @@ declare class Session {
|
|
|
281
283
|
off(event: string, handler: (data: unknown) => void): void;
|
|
282
284
|
private setupToolInvokeHandler;
|
|
283
285
|
private setupEventHandlers;
|
|
284
|
-
|
|
286
|
+
protected emit(event: string, data: unknown): void;
|
|
285
287
|
/**
|
|
286
288
|
* Check for changes in the tool catalog and emit 'tools:changed' if needed
|
|
287
289
|
*/
|
|
@@ -320,6 +322,39 @@ declare class Environment extends Session {
|
|
|
320
322
|
get permissionProfileId(): string;
|
|
321
323
|
/** The GraphQL API endpoint URL */
|
|
322
324
|
get apiEndpoint(): string;
|
|
325
|
+
/** The last known graph container status, updated by checkReadiness() or on heartbeat */
|
|
326
|
+
graphContainerStatus: {
|
|
327
|
+
lastKeepAliveAt: number;
|
|
328
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
329
|
+
} | null;
|
|
330
|
+
/**
|
|
331
|
+
* Check if the graph container is ready and warm.
|
|
332
|
+
*
|
|
333
|
+
* Sends a lightweight heartbeat RPC to the Session DO which internally
|
|
334
|
+
* pings the FalkorDB container. The response includes `graphContainerStatus`,
|
|
335
|
+
* which is stored locally and emitted as a `readiness` event.
|
|
336
|
+
*
|
|
337
|
+
* Use this method to proactively warm the graph container before any
|
|
338
|
+
* GraphQL query that requires it, or to poll the container's state in
|
|
339
|
+
* the background.
|
|
340
|
+
*
|
|
341
|
+
* @returns The current graph container status object
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const status = await env.checkReadiness();
|
|
346
|
+
* console.log(status.status); // 'hot' | 'warming' | 'unknown'
|
|
347
|
+
*
|
|
348
|
+
* // Or listen for live updates
|
|
349
|
+
* env.on('readiness', (status) => {
|
|
350
|
+
* console.log('Graph is now:', status.status);
|
|
351
|
+
* });
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
checkReadiness(): Promise<{
|
|
355
|
+
lastKeepAliveAt: number;
|
|
356
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
357
|
+
}>;
|
|
323
358
|
/**
|
|
324
359
|
* Convert a class name + real-world ID into a unique graph path.
|
|
325
360
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Automerge from '@automerge/automerge';
|
|
2
|
-
import { W as WSClientOptions, T as ToolWithHandler, P as PublishToolsResult, J as Job, a as ToolHandler, I as InstanceToolHandler, b as ToolInfo, c as ToolsChangedEvent, D as DomainState, G as GranularOptions, R as RecordUserOptions, U as User, C as ConnectOptions, E as EnvironmentData, d as GraphQLResult, e as DefineRelationshipOptions, f as RelationshipInfo, M as ModelRef, g as ManifestContent, h as RecordObjectOptions, i as RecordObjectResult, S as SandboxListResponse, j as Sandbox, k as CreateSandboxData, l as DeleteResponse, m as PermissionProfile, n as CreatePermissionProfileData, o as CreateEnvironmentData, p as Subject, A as AssignmentListResponse } from './types-
|
|
3
|
-
export {
|
|
2
|
+
import { W as WSClientOptions, T as ToolWithHandler, P as PublishToolsResult, J as Job, a as ToolHandler, I as InstanceToolHandler, b as ToolInfo, c as ToolsChangedEvent, D as DomainState, G as GranularOptions, R as RecordUserOptions, U as User, C as ConnectOptions, E as EnvironmentData, d as GraphQLResult, e as DefineRelationshipOptions, f as RelationshipInfo, M as ModelRef, g as ManifestContent, h as RecordObjectOptions, i as RecordObjectResult, S as SandboxListResponse, j as Sandbox, k as CreateSandboxData, l as DeleteResponse, m as PermissionProfile, n as CreatePermissionProfileData, o as CreateEnvironmentData, p as Subject, A as AssignmentListResponse } from './types-CnX4jXYQ.js';
|
|
3
|
+
export { a2 as APIError, u as Assignment, z as Build, F as BuildListResponse, B as BuildPolicy, y as BuildStatus, v as EnvironmentListResponse, r as GranularAuth, H as JobStatus, K as JobSubmitResult, w as Manifest, a0 as ManifestImport, x as ManifestListResponse, $ as ManifestOperation, Z as ManifestPropertySpec, _ as ManifestRelationshipDef, a1 as ManifestVolume, t as PermissionProfileListResponse, s as PermissionRules, L as Prompt, N as RPCRequest, V as RPCRequestFromServer, O as RPCResponse, Q as SyncMessage, X as ToolInvokeParams, Y as ToolResultParams, q as ToolSchema } from './types-CnX4jXYQ.js';
|
|
4
4
|
import { Doc } from '@automerge/automerge/slim';
|
|
5
5
|
|
|
6
6
|
declare class WSClient {
|
|
@@ -107,6 +107,10 @@ declare class Session {
|
|
|
107
107
|
ok: boolean;
|
|
108
108
|
environmentId?: string;
|
|
109
109
|
docId?: string;
|
|
110
|
+
graphContainerStatus?: {
|
|
111
|
+
lastKeepAliveAt: number;
|
|
112
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
113
|
+
};
|
|
110
114
|
}>;
|
|
111
115
|
/**
|
|
112
116
|
* Publish tools to the sandbox and register handlers for reverse-RPC.
|
|
@@ -245,21 +249,19 @@ declare class Session {
|
|
|
245
249
|
*/
|
|
246
250
|
getDomain(): Promise<DomainState>;
|
|
247
251
|
/**
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
*
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
* Falls back to generating markdown docs from the domain summary if
|
|
262
|
-
* the synthesis server is unavailable.
|
|
252
|
+
* Fetch a domain package part from the backend (no fallback).
|
|
253
|
+
*/
|
|
254
|
+
private fetchDomainPart;
|
|
255
|
+
/**
|
|
256
|
+
* Get TypeScript class declarations for the current domain (for LLM/code gen).
|
|
257
|
+
*/
|
|
258
|
+
getDomainTypes(): Promise<string>;
|
|
259
|
+
/**
|
|
260
|
+
* Get Markdown documentation for the current domain (human-readable).
|
|
261
|
+
*/
|
|
262
|
+
getDomainDocs(): Promise<string>;
|
|
263
|
+
/**
|
|
264
|
+
* Get domain documentation for LLMs. Returns types (preferred) or fallback.
|
|
263
265
|
*/
|
|
264
266
|
getDomainDocumentation(): Promise<string>;
|
|
265
267
|
/**
|
|
@@ -281,7 +283,7 @@ declare class Session {
|
|
|
281
283
|
off(event: string, handler: (data: unknown) => void): void;
|
|
282
284
|
private setupToolInvokeHandler;
|
|
283
285
|
private setupEventHandlers;
|
|
284
|
-
|
|
286
|
+
protected emit(event: string, data: unknown): void;
|
|
285
287
|
/**
|
|
286
288
|
* Check for changes in the tool catalog and emit 'tools:changed' if needed
|
|
287
289
|
*/
|
|
@@ -320,6 +322,39 @@ declare class Environment extends Session {
|
|
|
320
322
|
get permissionProfileId(): string;
|
|
321
323
|
/** The GraphQL API endpoint URL */
|
|
322
324
|
get apiEndpoint(): string;
|
|
325
|
+
/** The last known graph container status, updated by checkReadiness() or on heartbeat */
|
|
326
|
+
graphContainerStatus: {
|
|
327
|
+
lastKeepAliveAt: number;
|
|
328
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
329
|
+
} | null;
|
|
330
|
+
/**
|
|
331
|
+
* Check if the graph container is ready and warm.
|
|
332
|
+
*
|
|
333
|
+
* Sends a lightweight heartbeat RPC to the Session DO which internally
|
|
334
|
+
* pings the FalkorDB container. The response includes `graphContainerStatus`,
|
|
335
|
+
* which is stored locally and emitted as a `readiness` event.
|
|
336
|
+
*
|
|
337
|
+
* Use this method to proactively warm the graph container before any
|
|
338
|
+
* GraphQL query that requires it, or to poll the container's state in
|
|
339
|
+
* the background.
|
|
340
|
+
*
|
|
341
|
+
* @returns The current graph container status object
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const status = await env.checkReadiness();
|
|
346
|
+
* console.log(status.status); // 'hot' | 'warming' | 'unknown'
|
|
347
|
+
*
|
|
348
|
+
* // Or listen for live updates
|
|
349
|
+
* env.on('readiness', (status) => {
|
|
350
|
+
* console.log('Graph is now:', status.status);
|
|
351
|
+
* });
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
checkReadiness(): Promise<{
|
|
355
|
+
lastKeepAliveAt: number;
|
|
356
|
+
status: 'warming' | 'hot' | 'unknown';
|
|
357
|
+
}>;
|
|
323
358
|
/**
|
|
324
359
|
* Convert a class name + real-world ID into a unique graph path.
|
|
325
360
|
*
|