@granular-software/sdk 0.4.11 → 0.4.13
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/cli/index.js +124 -0
- package/dist/index.d.mts +130 -3
- package/dist/index.d.ts +130 -3
- package/dist/index.js +354 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +353 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/cli/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var crypto = require('crypto');
|
|
|
10
10
|
var process6 = require('process');
|
|
11
11
|
var os = require('os');
|
|
12
12
|
var tty = require('tty');
|
|
13
|
+
var metamodelPresetDefault = require('@granular-software/metamodel-preset-default');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
|
|
@@ -8833,10 +8834,29 @@ function sandboxDocScopeSection(projectName) {
|
|
|
8833
8834
|
|
|
8834
8835
|
If **syntax** or **Granular behavior** is unclear, use the manifest guide; use **this** file for **ontology facts** for **${projectName}**.`;
|
|
8835
8836
|
}
|
|
8837
|
+
function getFieldMetamodelDocRows() {
|
|
8838
|
+
return metamodelPresetDefault.collectMetamodelDocRows("fieldRows");
|
|
8839
|
+
}
|
|
8840
|
+
function getModelMetamodelDocRows() {
|
|
8841
|
+
return metamodelPresetDefault.collectMetamodelDocRows("modelRows");
|
|
8842
|
+
}
|
|
8843
|
+
function getEffectMetamodelDocRows() {
|
|
8844
|
+
return metamodelPresetDefault.collectMetamodelDocRows("effectRows");
|
|
8845
|
+
}
|
|
8846
|
+
function renderMetamodelDocTable(rows) {
|
|
8847
|
+
return [
|
|
8848
|
+
"| Key | Meaning |",
|
|
8849
|
+
"|-----|---------|",
|
|
8850
|
+
...rows.map((row) => `| \`${row.key}\` | ${row.description} |`)
|
|
8851
|
+
].join("\n");
|
|
8852
|
+
}
|
|
8836
8853
|
|
|
8837
8854
|
// src/cli/agent-docs/manifest-guide.ts
|
|
8838
8855
|
function generateManifestAgentGuide(options) {
|
|
8839
8856
|
const { projectName } = options;
|
|
8857
|
+
const fieldMetamodelTable = renderMetamodelDocTable(getFieldMetamodelDocRows());
|
|
8858
|
+
const modelMetamodelTable = renderMetamodelDocTable(getModelMetamodelDocRows());
|
|
8859
|
+
const effectMetamodelTable = renderMetamodelDocTable(getEffectMetamodelDocRows());
|
|
8840
8860
|
return `# Granular manifest guide (for coding agents)
|
|
8841
8861
|
|
|
8842
8862
|
This guide is for **coding agents** who may have **no prior context on Granular**. It explains the product, core terms, how to **author** \`granular.json\`, **build** the domain, and use the SDK (\`connect\` \u2192 **environment**, \`recordObject\`, \`submitJob\`, **effects**). For **this repository\u2019s** exact class names, relationship keys, and effect payloads only, see [GRANULAR_SANDBOX.md](../GRANULAR_SANDBOX.md).
|
|
@@ -8942,6 +8962,66 @@ Each key under \`has\` is a **field name** on the class. Each value is a **field
|
|
|
8942
8962
|
- Every scalar field should have \`"type": "..."\`.
|
|
8943
8963
|
- Do **not** store links to other entities as opaque strings when you can use **relationships** (next section).
|
|
8944
8964
|
|
|
8965
|
+
### Field metamodels
|
|
8966
|
+
|
|
8967
|
+
Scalar fields can carry lightweight metamodels directly in their field spec:
|
|
8968
|
+
|
|
8969
|
+
\`\`\`json
|
|
8970
|
+
{
|
|
8971
|
+
"create": "ticket",
|
|
8972
|
+
"extends": "@std/class",
|
|
8973
|
+
"note": "Ticket workflow object",
|
|
8974
|
+
"stateMachines": [
|
|
8975
|
+
{
|
|
8976
|
+
"name": "lifecycle",
|
|
8977
|
+
"entryState": "draft",
|
|
8978
|
+
"states": ["draft", "active", { "name": "done", "isFinal": true }],
|
|
8979
|
+
"finalStates": ["canceled"],
|
|
8980
|
+
"transitions": [
|
|
8981
|
+
{ "name": "activate", "from": "draft", "to": "active" },
|
|
8982
|
+
{ "name": "complete", "from": "active", "to": "done" },
|
|
8983
|
+
{ "name": "cancel", "from": "draft", "to": "canceled" }
|
|
8984
|
+
]
|
|
8985
|
+
}
|
|
8986
|
+
],
|
|
8987
|
+
"has": {
|
|
8988
|
+
"title": {
|
|
8989
|
+
"type": "string",
|
|
8990
|
+
"required": true,
|
|
8991
|
+
"note": "Must use the canonical prefix",
|
|
8992
|
+
"filterBy": true,
|
|
8993
|
+
"validate": [
|
|
8994
|
+
{ "operator": "regex", "stringValue": "^TKT-[A-Z0-9-]+$" }
|
|
8995
|
+
]
|
|
8996
|
+
},
|
|
8997
|
+
"status": {
|
|
8998
|
+
"type": "string",
|
|
8999
|
+
"enum": {
|
|
9000
|
+
"values": ["draft", "active", "done", "canceled"],
|
|
9001
|
+
"message": "Invalid ticket status"
|
|
9002
|
+
},
|
|
9003
|
+
"filterBy": ["equal_to", "contains"]
|
|
9004
|
+
},
|
|
9005
|
+
"estimate": {
|
|
9006
|
+
"type": "number",
|
|
9007
|
+
"filterBy": true,
|
|
9008
|
+
"validate": [
|
|
9009
|
+
{ "operator": "gt", "numberValue": 0 },
|
|
9010
|
+
{ "operator": "lt", "numberValue": 100 }
|
|
9011
|
+
]
|
|
9012
|
+
}
|
|
9013
|
+
}
|
|
9014
|
+
}
|
|
9015
|
+
\`\`\`
|
|
9016
|
+
|
|
9017
|
+
Supported field metamodel keys:
|
|
9018
|
+
|
|
9019
|
+
${fieldMetamodelTable}
|
|
9020
|
+
|
|
9021
|
+
Supported model-level metamodel keys:
|
|
9022
|
+
|
|
9023
|
+
${modelMetamodelTable}
|
|
9024
|
+
|
|
8945
9025
|
---
|
|
8946
9026
|
|
|
8947
9027
|
## Operations: \`defineRelationship\` (model links precisely)
|
|
@@ -9027,6 +9107,50 @@ Example:
|
|
|
9027
9107
|
|
|
9028
9108
|
**Permissions:** \`connect({ permissions: [...] })\` assigns profiles (e.g. \`default\`) that can allow or deny which effects a user may call.
|
|
9029
9109
|
|
|
9110
|
+
### Effect metamodels
|
|
9111
|
+
|
|
9112
|
+
Effects can declare runtime behaviors under \`withEffect.metamodels\`:
|
|
9113
|
+
|
|
9114
|
+
\`\`\`json
|
|
9115
|
+
{
|
|
9116
|
+
"withEffect": {
|
|
9117
|
+
"name": "publish_ticket",
|
|
9118
|
+
"attachedClass": "ticket",
|
|
9119
|
+
"inputSchema": {
|
|
9120
|
+
"type": "object",
|
|
9121
|
+
"properties": { "audience": { "type": "string" } }
|
|
9122
|
+
},
|
|
9123
|
+
"outputSchema": {
|
|
9124
|
+
"type": "object",
|
|
9125
|
+
"properties": { "ok": { "type": "boolean" } }
|
|
9126
|
+
},
|
|
9127
|
+
"metamodels": {
|
|
9128
|
+
"postCondition": {
|
|
9129
|
+
"condition": "result.ok == true",
|
|
9130
|
+
"description": "Publishing must report success"
|
|
9131
|
+
},
|
|
9132
|
+
"dryRun": {
|
|
9133
|
+
"enabled": true,
|
|
9134
|
+
"description": "Preview publishing before sending"
|
|
9135
|
+
},
|
|
9136
|
+
"reverse": {
|
|
9137
|
+
"handler": "unpublish_ticket",
|
|
9138
|
+
"description": "Undo a publication"
|
|
9139
|
+
},
|
|
9140
|
+
"approvalRequired": {
|
|
9141
|
+
"required": true,
|
|
9142
|
+
"reason": "Publishing is user-visible",
|
|
9143
|
+
"mode": "confirm"
|
|
9144
|
+
}
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
}
|
|
9148
|
+
\`\`\`
|
|
9149
|
+
|
|
9150
|
+
Supported effect metamodel keys:
|
|
9151
|
+
|
|
9152
|
+
${effectMetamodelTable}
|
|
9153
|
+
|
|
9030
9154
|
---
|
|
9031
9155
|
|
|
9032
9156
|
## IDs and labels
|
package/dist/index.d.mts
CHANGED
|
@@ -304,6 +304,38 @@ interface EffectHandlerContext {
|
|
|
304
304
|
identityId?: string;
|
|
305
305
|
principalId?: string;
|
|
306
306
|
};
|
|
307
|
+
behaviors?: ResolvedEffectBehaviors;
|
|
308
|
+
invocation?: EffectInvocationMetadata;
|
|
309
|
+
}
|
|
310
|
+
interface ResolvedEffectPostCondition {
|
|
311
|
+
condition: string;
|
|
312
|
+
description?: string;
|
|
313
|
+
}
|
|
314
|
+
interface ResolvedEffectDryRun {
|
|
315
|
+
enabled: boolean;
|
|
316
|
+
description?: string;
|
|
317
|
+
}
|
|
318
|
+
interface ResolvedEffectReverse {
|
|
319
|
+
handler?: string;
|
|
320
|
+
description?: string;
|
|
321
|
+
}
|
|
322
|
+
interface ResolvedEffectApprovalRequired {
|
|
323
|
+
required: boolean;
|
|
324
|
+
reason?: string;
|
|
325
|
+
mode?: string;
|
|
326
|
+
}
|
|
327
|
+
interface ResolvedEffectBehaviors {
|
|
328
|
+
postCondition?: ResolvedEffectPostCondition;
|
|
329
|
+
dryRun?: ResolvedEffectDryRun;
|
|
330
|
+
reverse?: ResolvedEffectReverse;
|
|
331
|
+
approvalRequired?: ResolvedEffectApprovalRequired;
|
|
332
|
+
}
|
|
333
|
+
type EffectInvocationMode = 'execute' | 'dryRun' | 'reverse';
|
|
334
|
+
interface EffectInvocationMetadata {
|
|
335
|
+
mode?: EffectInvocationMode;
|
|
336
|
+
reverseHandler?: string;
|
|
337
|
+
sourceEffectKey?: string;
|
|
338
|
+
sourceEffectName?: string;
|
|
307
339
|
}
|
|
308
340
|
type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
|
|
309
341
|
/**
|
|
@@ -373,6 +405,8 @@ interface ToolSchema {
|
|
|
373
405
|
* passed as the first argument to the handler).
|
|
374
406
|
*/
|
|
375
407
|
static?: boolean;
|
|
408
|
+
/** Declarative runtime behaviors attached to the effect. */
|
|
409
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
376
410
|
}
|
|
377
411
|
type EffectSchema = ToolSchema;
|
|
378
412
|
/**
|
|
@@ -387,6 +421,8 @@ type EffectSchema = ToolSchema;
|
|
|
387
421
|
*/
|
|
388
422
|
interface ToolWithHandler extends ToolSchema {
|
|
389
423
|
handler: ToolHandler | InstanceToolHandler;
|
|
424
|
+
dryRunHandler?: ToolHandler | InstanceToolHandler;
|
|
425
|
+
reverseHandler?: ToolHandler | InstanceToolHandler;
|
|
390
426
|
}
|
|
391
427
|
type EffectWithHandler = ToolWithHandler;
|
|
392
428
|
/**
|
|
@@ -411,6 +447,7 @@ interface DomainState {
|
|
|
411
447
|
description?: string;
|
|
412
448
|
inputSchema?: Record<string, unknown>;
|
|
413
449
|
outputSchema?: Record<string, unknown>;
|
|
450
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
414
451
|
}>;
|
|
415
452
|
[key: string]: unknown;
|
|
416
453
|
}
|
|
@@ -437,6 +474,8 @@ interface ToolInfo {
|
|
|
437
474
|
className?: string;
|
|
438
475
|
/** Whether this is a static method */
|
|
439
476
|
static?: boolean;
|
|
477
|
+
/** Declarative runtime behaviors attached to the effect. */
|
|
478
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
440
479
|
}
|
|
441
480
|
interface EffectInfo extends ToolInfo {
|
|
442
481
|
}
|
|
@@ -457,7 +496,7 @@ interface EffectsChangedEvent extends ToolsChangedEvent {
|
|
|
457
496
|
}
|
|
458
497
|
type EffectHandler = ToolHandler;
|
|
459
498
|
type InstanceEffectHandler = InstanceToolHandler;
|
|
460
|
-
type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
|
|
499
|
+
type JobStatus = 'queued' | 'running' | 'awaitingTool' | 'awaitingHuman' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
|
|
461
500
|
type JobFeedbackSentiment = 'good' | 'bad';
|
|
462
501
|
interface JobFeedbackToolCall {
|
|
463
502
|
callId?: string;
|
|
@@ -529,8 +568,15 @@ interface Prompt {
|
|
|
529
568
|
type: 'confirm' | 'choice' | 'input';
|
|
530
569
|
title: string;
|
|
531
570
|
message: string;
|
|
532
|
-
options?: string
|
|
571
|
+
options?: Array<string | {
|
|
572
|
+
value: string;
|
|
573
|
+
label: string;
|
|
574
|
+
description?: string;
|
|
575
|
+
}>;
|
|
533
576
|
defaultValue?: unknown;
|
|
577
|
+
placeholder?: string;
|
|
578
|
+
allowEmpty?: boolean;
|
|
579
|
+
metadata?: Record<string, unknown>;
|
|
534
580
|
}
|
|
535
581
|
type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
|
|
536
582
|
interface SessionHeapFieldValue {
|
|
@@ -788,6 +834,65 @@ interface ManifestPropertySpec {
|
|
|
788
834
|
type?: string;
|
|
789
835
|
description?: string;
|
|
790
836
|
required?: boolean;
|
|
837
|
+
note?: string | string[];
|
|
838
|
+
enum?: string[] | ManifestEnumRuleSpec;
|
|
839
|
+
filterBy?: boolean | string[] | ManifestFilterBySpec;
|
|
840
|
+
validate?: ManifestValidationRuleSpec[];
|
|
841
|
+
}
|
|
842
|
+
type ManifestValidationOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'true' | 'false' | 'regex' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with';
|
|
843
|
+
interface ManifestEnumRuleSpec {
|
|
844
|
+
values: string[];
|
|
845
|
+
message?: string;
|
|
846
|
+
}
|
|
847
|
+
interface ManifestFilterBySpec {
|
|
848
|
+
operators: string[];
|
|
849
|
+
scalarType?: string;
|
|
850
|
+
}
|
|
851
|
+
interface ManifestValidationRuleSpec {
|
|
852
|
+
operator: ManifestValidationOperator;
|
|
853
|
+
stringValue?: string;
|
|
854
|
+
numberValue?: number;
|
|
855
|
+
booleanValue?: boolean;
|
|
856
|
+
message?: string;
|
|
857
|
+
}
|
|
858
|
+
interface ManifestStateMachineStateSpec {
|
|
859
|
+
name: string;
|
|
860
|
+
isFinal?: boolean;
|
|
861
|
+
}
|
|
862
|
+
interface ManifestStateMachineTransitionSpec {
|
|
863
|
+
name: string;
|
|
864
|
+
from: string;
|
|
865
|
+
to: string;
|
|
866
|
+
}
|
|
867
|
+
interface ManifestStateMachineSpec {
|
|
868
|
+
name: string;
|
|
869
|
+
entryState: string;
|
|
870
|
+
states: Array<string | ManifestStateMachineStateSpec>;
|
|
871
|
+
transitions: ManifestStateMachineTransitionSpec[];
|
|
872
|
+
finalStates?: string[];
|
|
873
|
+
}
|
|
874
|
+
interface ManifestPostConditionSpec {
|
|
875
|
+
condition: string;
|
|
876
|
+
description?: string;
|
|
877
|
+
}
|
|
878
|
+
interface ManifestDryRunSpec {
|
|
879
|
+
enabled?: boolean;
|
|
880
|
+
description?: string;
|
|
881
|
+
}
|
|
882
|
+
interface ManifestReverseSpec {
|
|
883
|
+
handler?: string;
|
|
884
|
+
description?: string;
|
|
885
|
+
}
|
|
886
|
+
interface ManifestApprovalRequiredSpec {
|
|
887
|
+
required?: boolean;
|
|
888
|
+
reason?: string;
|
|
889
|
+
mode?: string;
|
|
890
|
+
}
|
|
891
|
+
interface ManifestEffectMetamodelSpec {
|
|
892
|
+
postCondition?: string | ManifestPostConditionSpec;
|
|
893
|
+
dryRun?: boolean | ManifestDryRunSpec;
|
|
894
|
+
reverse?: string | ManifestReverseSpec;
|
|
895
|
+
approvalRequired?: boolean | ManifestApprovalRequiredSpec;
|
|
791
896
|
}
|
|
792
897
|
/**
|
|
793
898
|
* Relationship definition between two classes
|
|
@@ -825,6 +930,7 @@ interface ManifestEffectDeclaration {
|
|
|
825
930
|
outputSchema?: ManifestEffectSchema;
|
|
826
931
|
stability?: 'stable' | 'experimental' | 'deprecated';
|
|
827
932
|
tags?: string[];
|
|
933
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
828
934
|
}
|
|
829
935
|
/**
|
|
830
936
|
* A single operation in a manifest volume
|
|
@@ -840,6 +946,10 @@ interface ManifestOperation {
|
|
|
840
946
|
instanceOf?: string;
|
|
841
947
|
/** Define submodels/fields */
|
|
842
948
|
has?: Record<string, ManifestPropertySpec>;
|
|
949
|
+
/** Advisory notes attached to the model/class itself */
|
|
950
|
+
note?: string | string[];
|
|
951
|
+
/** State machines attached to the created or targeted class */
|
|
952
|
+
stateMachines?: ManifestStateMachineSpec[];
|
|
843
953
|
/** Define a relationship between two classes */
|
|
844
954
|
defineRelationship?: ManifestRelationshipDef;
|
|
845
955
|
/** Declare a build-owned effect */
|
|
@@ -1377,6 +1487,13 @@ declare class Environment extends Session {
|
|
|
1377
1487
|
* Strips the alias prefix, returning the bare model path.
|
|
1378
1488
|
*/
|
|
1379
1489
|
private _resolveAlias;
|
|
1490
|
+
private _runGraphql;
|
|
1491
|
+
private _applyFieldMetamodels;
|
|
1492
|
+
private _applyModelMetamodels;
|
|
1493
|
+
private _ensureWorkspaceToolsRoot;
|
|
1494
|
+
private _storeEffectSchemas;
|
|
1495
|
+
private _applyEffectMetamodels;
|
|
1496
|
+
private _applyEffectDeclaration;
|
|
1380
1497
|
/**
|
|
1381
1498
|
* Apply a single manifest operation via GraphQL
|
|
1382
1499
|
*/
|
|
@@ -1547,6 +1664,7 @@ declare class Granular {
|
|
|
1547
1664
|
private serializeEffect;
|
|
1548
1665
|
private publishSandboxEffectCatalog;
|
|
1549
1666
|
private syncSandboxEffectCatalog;
|
|
1667
|
+
private recoverEffectHost;
|
|
1550
1668
|
private startEffectHostHeartbeat;
|
|
1551
1669
|
private stopEffectHostHeartbeat;
|
|
1552
1670
|
private synchronizeEffectHost;
|
|
@@ -1649,4 +1767,13 @@ declare class Granular {
|
|
|
1649
1767
|
private request;
|
|
1650
1768
|
}
|
|
1651
1769
|
|
|
1652
|
-
|
|
1770
|
+
type EffectRuntimeRequest = {
|
|
1771
|
+
effectKey: string;
|
|
1772
|
+
effectName: string;
|
|
1773
|
+
input: unknown;
|
|
1774
|
+
context?: EffectHandlerContext;
|
|
1775
|
+
};
|
|
1776
|
+
declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
|
|
1777
|
+
declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
|
|
1778
|
+
|
|
1779
|
+
export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
|
package/dist/index.d.ts
CHANGED
|
@@ -304,6 +304,38 @@ interface EffectHandlerContext {
|
|
|
304
304
|
identityId?: string;
|
|
305
305
|
principalId?: string;
|
|
306
306
|
};
|
|
307
|
+
behaviors?: ResolvedEffectBehaviors;
|
|
308
|
+
invocation?: EffectInvocationMetadata;
|
|
309
|
+
}
|
|
310
|
+
interface ResolvedEffectPostCondition {
|
|
311
|
+
condition: string;
|
|
312
|
+
description?: string;
|
|
313
|
+
}
|
|
314
|
+
interface ResolvedEffectDryRun {
|
|
315
|
+
enabled: boolean;
|
|
316
|
+
description?: string;
|
|
317
|
+
}
|
|
318
|
+
interface ResolvedEffectReverse {
|
|
319
|
+
handler?: string;
|
|
320
|
+
description?: string;
|
|
321
|
+
}
|
|
322
|
+
interface ResolvedEffectApprovalRequired {
|
|
323
|
+
required: boolean;
|
|
324
|
+
reason?: string;
|
|
325
|
+
mode?: string;
|
|
326
|
+
}
|
|
327
|
+
interface ResolvedEffectBehaviors {
|
|
328
|
+
postCondition?: ResolvedEffectPostCondition;
|
|
329
|
+
dryRun?: ResolvedEffectDryRun;
|
|
330
|
+
reverse?: ResolvedEffectReverse;
|
|
331
|
+
approvalRequired?: ResolvedEffectApprovalRequired;
|
|
332
|
+
}
|
|
333
|
+
type EffectInvocationMode = 'execute' | 'dryRun' | 'reverse';
|
|
334
|
+
interface EffectInvocationMetadata {
|
|
335
|
+
mode?: EffectInvocationMode;
|
|
336
|
+
reverseHandler?: string;
|
|
337
|
+
sourceEffectKey?: string;
|
|
338
|
+
sourceEffectName?: string;
|
|
307
339
|
}
|
|
308
340
|
type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
|
|
309
341
|
/**
|
|
@@ -373,6 +405,8 @@ interface ToolSchema {
|
|
|
373
405
|
* passed as the first argument to the handler).
|
|
374
406
|
*/
|
|
375
407
|
static?: boolean;
|
|
408
|
+
/** Declarative runtime behaviors attached to the effect. */
|
|
409
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
376
410
|
}
|
|
377
411
|
type EffectSchema = ToolSchema;
|
|
378
412
|
/**
|
|
@@ -387,6 +421,8 @@ type EffectSchema = ToolSchema;
|
|
|
387
421
|
*/
|
|
388
422
|
interface ToolWithHandler extends ToolSchema {
|
|
389
423
|
handler: ToolHandler | InstanceToolHandler;
|
|
424
|
+
dryRunHandler?: ToolHandler | InstanceToolHandler;
|
|
425
|
+
reverseHandler?: ToolHandler | InstanceToolHandler;
|
|
390
426
|
}
|
|
391
427
|
type EffectWithHandler = ToolWithHandler;
|
|
392
428
|
/**
|
|
@@ -411,6 +447,7 @@ interface DomainState {
|
|
|
411
447
|
description?: string;
|
|
412
448
|
inputSchema?: Record<string, unknown>;
|
|
413
449
|
outputSchema?: Record<string, unknown>;
|
|
450
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
414
451
|
}>;
|
|
415
452
|
[key: string]: unknown;
|
|
416
453
|
}
|
|
@@ -437,6 +474,8 @@ interface ToolInfo {
|
|
|
437
474
|
className?: string;
|
|
438
475
|
/** Whether this is a static method */
|
|
439
476
|
static?: boolean;
|
|
477
|
+
/** Declarative runtime behaviors attached to the effect. */
|
|
478
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
440
479
|
}
|
|
441
480
|
interface EffectInfo extends ToolInfo {
|
|
442
481
|
}
|
|
@@ -457,7 +496,7 @@ interface EffectsChangedEvent extends ToolsChangedEvent {
|
|
|
457
496
|
}
|
|
458
497
|
type EffectHandler = ToolHandler;
|
|
459
498
|
type InstanceEffectHandler = InstanceToolHandler;
|
|
460
|
-
type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
|
|
499
|
+
type JobStatus = 'queued' | 'running' | 'awaitingTool' | 'awaitingHuman' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
|
|
461
500
|
type JobFeedbackSentiment = 'good' | 'bad';
|
|
462
501
|
interface JobFeedbackToolCall {
|
|
463
502
|
callId?: string;
|
|
@@ -529,8 +568,15 @@ interface Prompt {
|
|
|
529
568
|
type: 'confirm' | 'choice' | 'input';
|
|
530
569
|
title: string;
|
|
531
570
|
message: string;
|
|
532
|
-
options?: string
|
|
571
|
+
options?: Array<string | {
|
|
572
|
+
value: string;
|
|
573
|
+
label: string;
|
|
574
|
+
description?: string;
|
|
575
|
+
}>;
|
|
533
576
|
defaultValue?: unknown;
|
|
577
|
+
placeholder?: string;
|
|
578
|
+
allowEmpty?: boolean;
|
|
579
|
+
metadata?: Record<string, unknown>;
|
|
534
580
|
}
|
|
535
581
|
type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
|
|
536
582
|
interface SessionHeapFieldValue {
|
|
@@ -788,6 +834,65 @@ interface ManifestPropertySpec {
|
|
|
788
834
|
type?: string;
|
|
789
835
|
description?: string;
|
|
790
836
|
required?: boolean;
|
|
837
|
+
note?: string | string[];
|
|
838
|
+
enum?: string[] | ManifestEnumRuleSpec;
|
|
839
|
+
filterBy?: boolean | string[] | ManifestFilterBySpec;
|
|
840
|
+
validate?: ManifestValidationRuleSpec[];
|
|
841
|
+
}
|
|
842
|
+
type ManifestValidationOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'true' | 'false' | 'regex' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with';
|
|
843
|
+
interface ManifestEnumRuleSpec {
|
|
844
|
+
values: string[];
|
|
845
|
+
message?: string;
|
|
846
|
+
}
|
|
847
|
+
interface ManifestFilterBySpec {
|
|
848
|
+
operators: string[];
|
|
849
|
+
scalarType?: string;
|
|
850
|
+
}
|
|
851
|
+
interface ManifestValidationRuleSpec {
|
|
852
|
+
operator: ManifestValidationOperator;
|
|
853
|
+
stringValue?: string;
|
|
854
|
+
numberValue?: number;
|
|
855
|
+
booleanValue?: boolean;
|
|
856
|
+
message?: string;
|
|
857
|
+
}
|
|
858
|
+
interface ManifestStateMachineStateSpec {
|
|
859
|
+
name: string;
|
|
860
|
+
isFinal?: boolean;
|
|
861
|
+
}
|
|
862
|
+
interface ManifestStateMachineTransitionSpec {
|
|
863
|
+
name: string;
|
|
864
|
+
from: string;
|
|
865
|
+
to: string;
|
|
866
|
+
}
|
|
867
|
+
interface ManifestStateMachineSpec {
|
|
868
|
+
name: string;
|
|
869
|
+
entryState: string;
|
|
870
|
+
states: Array<string | ManifestStateMachineStateSpec>;
|
|
871
|
+
transitions: ManifestStateMachineTransitionSpec[];
|
|
872
|
+
finalStates?: string[];
|
|
873
|
+
}
|
|
874
|
+
interface ManifestPostConditionSpec {
|
|
875
|
+
condition: string;
|
|
876
|
+
description?: string;
|
|
877
|
+
}
|
|
878
|
+
interface ManifestDryRunSpec {
|
|
879
|
+
enabled?: boolean;
|
|
880
|
+
description?: string;
|
|
881
|
+
}
|
|
882
|
+
interface ManifestReverseSpec {
|
|
883
|
+
handler?: string;
|
|
884
|
+
description?: string;
|
|
885
|
+
}
|
|
886
|
+
interface ManifestApprovalRequiredSpec {
|
|
887
|
+
required?: boolean;
|
|
888
|
+
reason?: string;
|
|
889
|
+
mode?: string;
|
|
890
|
+
}
|
|
891
|
+
interface ManifestEffectMetamodelSpec {
|
|
892
|
+
postCondition?: string | ManifestPostConditionSpec;
|
|
893
|
+
dryRun?: boolean | ManifestDryRunSpec;
|
|
894
|
+
reverse?: string | ManifestReverseSpec;
|
|
895
|
+
approvalRequired?: boolean | ManifestApprovalRequiredSpec;
|
|
791
896
|
}
|
|
792
897
|
/**
|
|
793
898
|
* Relationship definition between two classes
|
|
@@ -825,6 +930,7 @@ interface ManifestEffectDeclaration {
|
|
|
825
930
|
outputSchema?: ManifestEffectSchema;
|
|
826
931
|
stability?: 'stable' | 'experimental' | 'deprecated';
|
|
827
932
|
tags?: string[];
|
|
933
|
+
metamodels?: ManifestEffectMetamodelSpec;
|
|
828
934
|
}
|
|
829
935
|
/**
|
|
830
936
|
* A single operation in a manifest volume
|
|
@@ -840,6 +946,10 @@ interface ManifestOperation {
|
|
|
840
946
|
instanceOf?: string;
|
|
841
947
|
/** Define submodels/fields */
|
|
842
948
|
has?: Record<string, ManifestPropertySpec>;
|
|
949
|
+
/** Advisory notes attached to the model/class itself */
|
|
950
|
+
note?: string | string[];
|
|
951
|
+
/** State machines attached to the created or targeted class */
|
|
952
|
+
stateMachines?: ManifestStateMachineSpec[];
|
|
843
953
|
/** Define a relationship between two classes */
|
|
844
954
|
defineRelationship?: ManifestRelationshipDef;
|
|
845
955
|
/** Declare a build-owned effect */
|
|
@@ -1377,6 +1487,13 @@ declare class Environment extends Session {
|
|
|
1377
1487
|
* Strips the alias prefix, returning the bare model path.
|
|
1378
1488
|
*/
|
|
1379
1489
|
private _resolveAlias;
|
|
1490
|
+
private _runGraphql;
|
|
1491
|
+
private _applyFieldMetamodels;
|
|
1492
|
+
private _applyModelMetamodels;
|
|
1493
|
+
private _ensureWorkspaceToolsRoot;
|
|
1494
|
+
private _storeEffectSchemas;
|
|
1495
|
+
private _applyEffectMetamodels;
|
|
1496
|
+
private _applyEffectDeclaration;
|
|
1380
1497
|
/**
|
|
1381
1498
|
* Apply a single manifest operation via GraphQL
|
|
1382
1499
|
*/
|
|
@@ -1547,6 +1664,7 @@ declare class Granular {
|
|
|
1547
1664
|
private serializeEffect;
|
|
1548
1665
|
private publishSandboxEffectCatalog;
|
|
1549
1666
|
private syncSandboxEffectCatalog;
|
|
1667
|
+
private recoverEffectHost;
|
|
1550
1668
|
private startEffectHostHeartbeat;
|
|
1551
1669
|
private stopEffectHostHeartbeat;
|
|
1552
1670
|
private synchronizeEffectHost;
|
|
@@ -1649,4 +1767,13 @@ declare class Granular {
|
|
|
1649
1767
|
private request;
|
|
1650
1768
|
}
|
|
1651
1769
|
|
|
1652
|
-
|
|
1770
|
+
type EffectRuntimeRequest = {
|
|
1771
|
+
effectKey: string;
|
|
1772
|
+
effectName: string;
|
|
1773
|
+
input: unknown;
|
|
1774
|
+
context?: EffectHandlerContext;
|
|
1775
|
+
};
|
|
1776
|
+
declare function normalizeEffectBehaviors(value?: ManifestEffectMetamodelSpec | ResolvedEffectBehaviors | null): ResolvedEffectBehaviors;
|
|
1777
|
+
declare function invokeRegisteredEffect(effectMap: Map<string, ToolWithHandler>, request: EffectRuntimeRequest): Promise<unknown>;
|
|
1778
|
+
|
|
1779
|
+
export { type APIError, type AccessTokenProvider, type Assignment, type AssignmentListResponse, type Build, type BuildListResponse, type BuildPolicy, type BuildStatus, type ConnectOptions, type CreateEnvironmentData, type CreatePermissionProfileData, type CreateSandboxData, type DefineRelationshipOptions, type DeleteResponse, type DomainState, type EffectHandler, type EffectHandlerContext, type EffectInfo, type EffectInvocationMetadata, type EffectInvocationMode, type EffectSchema, type EffectWithHandler, type EffectsChangedEvent, type EndpointMode, Environment, type EnvironmentData, type EnvironmentListResponse, type EnvironmentRecordImportSummary, Granular, type GranularAuth, type GranularOptions, type GraphQLResult, type InstanceEffectHandler, type InstanceToolHandler, type Job, type JobFeedbackInput, type JobFeedbackMetadata, type JobFeedbackRecord, type JobFeedbackSentiment, type JobFeedbackToolCall, type JobStatus, type JobSubmitResult, type Manifest, type ManifestApprovalRequiredSpec, type ManifestContent, type ManifestDryRunSpec, type ManifestEffectDeclaration, type ManifestEffectMetamodelSpec, type ManifestEffectSchema, type ManifestEnumRuleSpec, type ManifestFilterBySpec, type ManifestImport, type ManifestListResponse, type ManifestOperation, type ManifestPostConditionSpec, type ManifestPropertySpec, type ManifestRelationshipDef, type ManifestReverseSpec, type ManifestStateMachineSpec, type ManifestStateMachineStateSpec, type ManifestStateMachineTransitionSpec, type ManifestValidationOperator, type ManifestValidationRuleSpec, type ManifestVolume, type ModelRef, type PermissionProfile, type PermissionProfileListResponse, type PermissionRules, type Prompt, type PublishEffectsResult, type PublishToolsResult, type RPCRequest, type RPCRequestFromServer, type RPCResponse, type RecordImport, type RecordImportItem, type RecordImportItemStatus, type RecordImportStats, type RecordImportStatus, type RecordObjectOptions, type RecordObjectResult, type RecordUserOptions, type RelationshipInfo, type ResolvedEffectApprovalRequired, type ResolvedEffectBehaviors, type ResolvedEffectDryRun, type ResolvedEffectPostCondition, type ResolvedEffectReverse, type Sandbox, type SandboxListResponse, Session, type SessionHeapEntry, type SessionHeapFieldType, type SessionHeapFieldValue, type SessionHeapList, type SessionHeapSnapshot, type SessionHeapVariable, type Subject, type SyncMessage, type ToolHandler, type ToolInfo, type ToolInvokeParams, type ToolResultParams, type ToolSchema, type ToolWithHandler, type ToolsChangedEvent, type User, WSClient, type WSClientOptions, type WSDisconnectInfo, type WSReconnectErrorInfo, invokeRegisteredEffect, normalizeEffectBehaviors };
|