@anchrd/colab-sdk 0.1.44 → 0.1.45
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/connectors/connectors.d.ts +3 -0
- package/dist/connectors/connectors.js +7 -0
- package/dist/grammar/grammar.d.ts +2 -0
- package/dist/grammar/grammar.js +7 -0
- package/dist/operators/operators.d.ts +129 -1
- package/dist/operators/operators.js +52 -3
- package/dist/relations/relations.d.ts +336 -0
- package/dist/relations/relations.js +125 -0
- package/dist/sdk.d.ts +3 -1
- package/dist/sdk.js +3 -1
- package/dist/types/types.d.ts +166 -0
- package/dist/types/types.js +112 -0
- package/dist/written/written.d.ts +4 -0
- package/dist/written/written.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const typeKinds: readonly ["object", "relation", "action", "actor"];
|
|
3
|
+
export declare const TypeKind: z.ZodEnum<{
|
|
4
|
+
object: "object";
|
|
5
|
+
action: "action";
|
|
6
|
+
relation: "relation";
|
|
7
|
+
actor: "actor";
|
|
8
|
+
}>;
|
|
9
|
+
export type TypeKind = z.infer<typeof TypeKind>;
|
|
10
|
+
export declare const typeStatuses: readonly ["experimental", "active", "deprecated"];
|
|
11
|
+
export declare const TypeStatus: z.ZodEnum<{
|
|
12
|
+
active: "active";
|
|
13
|
+
experimental: "experimental";
|
|
14
|
+
deprecated: "deprecated";
|
|
15
|
+
}>;
|
|
16
|
+
export type TypeStatus = z.infer<typeof TypeStatus>;
|
|
17
|
+
export declare const cardinalities: readonly ["one", "optional", "many"];
|
|
18
|
+
export declare const Cardinality: z.ZodEnum<{
|
|
19
|
+
optional: "optional";
|
|
20
|
+
one: "one";
|
|
21
|
+
many: "many";
|
|
22
|
+
}>;
|
|
23
|
+
export type Cardinality = z.infer<typeof Cardinality>;
|
|
24
|
+
export declare const baseObjectTypes: readonly ["document", "file", "table", "board", "task", "gadget", "skill", "goal", "source"];
|
|
25
|
+
export declare const baseActorTypes: readonly ["person", "machine", "system"];
|
|
26
|
+
export declare const baseActionTypes: readonly ["create", "update", "archive"];
|
|
27
|
+
export declare const TypeId: z.ZodTemplateLiteral<`type_${string}`>;
|
|
28
|
+
export type TypeId = z.infer<typeof TypeId>;
|
|
29
|
+
export declare const TypeRef: z.ZodString;
|
|
30
|
+
export type TypeRef = z.infer<typeof TypeRef>;
|
|
31
|
+
export declare const baseRef: (word: string) => TypeRef;
|
|
32
|
+
export declare const OntologyType: z.ZodObject<{
|
|
33
|
+
typeId: z.ZodString;
|
|
34
|
+
kind: z.ZodEnum<{
|
|
35
|
+
object: "object";
|
|
36
|
+
action: "action";
|
|
37
|
+
relation: "relation";
|
|
38
|
+
actor: "actor";
|
|
39
|
+
}>;
|
|
40
|
+
base: z.ZodBoolean;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
44
|
+
active: "active";
|
|
45
|
+
experimental: "experimental";
|
|
46
|
+
deprecated: "deprecated";
|
|
47
|
+
}>>;
|
|
48
|
+
sourceNodeId: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
49
|
+
from: z.ZodNullable<z.ZodString>;
|
|
50
|
+
to: z.ZodNullable<z.ZodString>;
|
|
51
|
+
cardinality: z.ZodNullable<z.ZodEnum<{
|
|
52
|
+
optional: "optional";
|
|
53
|
+
one: "one";
|
|
54
|
+
many: "many";
|
|
55
|
+
}>>;
|
|
56
|
+
arisesFrom: z.ZodNullable<z.ZodString>;
|
|
57
|
+
on: z.ZodNullable<z.ZodString>;
|
|
58
|
+
implementedBy: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
59
|
+
approval: z.ZodBoolean;
|
|
60
|
+
rev: z.ZodNullable<z.ZodInt>;
|
|
61
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export type OntologyType = z.infer<typeof OntologyType>;
|
|
64
|
+
export declare const TypeListInput: z.ZodObject<{
|
|
65
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
66
|
+
object: "object";
|
|
67
|
+
action: "action";
|
|
68
|
+
relation: "relation";
|
|
69
|
+
actor: "actor";
|
|
70
|
+
}>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export type TypeListInput = z.infer<typeof TypeListInput>;
|
|
73
|
+
export declare const TypeList: z.ZodObject<{
|
|
74
|
+
items: z.ZodArray<z.ZodObject<{
|
|
75
|
+
typeId: z.ZodString;
|
|
76
|
+
kind: z.ZodEnum<{
|
|
77
|
+
object: "object";
|
|
78
|
+
action: "action";
|
|
79
|
+
relation: "relation";
|
|
80
|
+
actor: "actor";
|
|
81
|
+
}>;
|
|
82
|
+
base: z.ZodBoolean;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
description: z.ZodString;
|
|
85
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
86
|
+
active: "active";
|
|
87
|
+
experimental: "experimental";
|
|
88
|
+
deprecated: "deprecated";
|
|
89
|
+
}>>;
|
|
90
|
+
sourceNodeId: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
91
|
+
from: z.ZodNullable<z.ZodString>;
|
|
92
|
+
to: z.ZodNullable<z.ZodString>;
|
|
93
|
+
cardinality: z.ZodNullable<z.ZodEnum<{
|
|
94
|
+
optional: "optional";
|
|
95
|
+
one: "one";
|
|
96
|
+
many: "many";
|
|
97
|
+
}>>;
|
|
98
|
+
arisesFrom: z.ZodNullable<z.ZodString>;
|
|
99
|
+
on: z.ZodNullable<z.ZodString>;
|
|
100
|
+
implementedBy: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
101
|
+
approval: z.ZodBoolean;
|
|
102
|
+
rev: z.ZodNullable<z.ZodInt>;
|
|
103
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
nextCursor: z.ZodNull;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
export type TypeList = z.infer<typeof TypeList>;
|
|
108
|
+
export declare const TypeCreateInput: z.ZodObject<{
|
|
109
|
+
kind: z.ZodEnum<{
|
|
110
|
+
object: "object";
|
|
111
|
+
action: "action";
|
|
112
|
+
relation: "relation";
|
|
113
|
+
actor: "actor";
|
|
114
|
+
}>;
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
description: z.ZodOptional<z.ZodString>;
|
|
117
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
118
|
+
active: "active";
|
|
119
|
+
experimental: "experimental";
|
|
120
|
+
deprecated: "deprecated";
|
|
121
|
+
}>>;
|
|
122
|
+
sourceNodeId: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
123
|
+
from: z.ZodOptional<z.ZodString>;
|
|
124
|
+
to: z.ZodOptional<z.ZodString>;
|
|
125
|
+
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
126
|
+
optional: "optional";
|
|
127
|
+
one: "one";
|
|
128
|
+
many: "many";
|
|
129
|
+
}>>;
|
|
130
|
+
on: z.ZodOptional<z.ZodString>;
|
|
131
|
+
implementedBy: z.ZodOptional<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
132
|
+
approval: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
idempotencyKey: z.ZodString;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
export type TypeCreateInput = z.infer<typeof TypeCreateInput>;
|
|
136
|
+
export declare const TypeUpdateInput: z.ZodObject<{
|
|
137
|
+
typeId: z.ZodTemplateLiteral<`type_${string}`>;
|
|
138
|
+
rev: z.ZodNumber;
|
|
139
|
+
name: z.ZodOptional<z.ZodString>;
|
|
140
|
+
description: z.ZodOptional<z.ZodString>;
|
|
141
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
142
|
+
active: "active";
|
|
143
|
+
experimental: "experimental";
|
|
144
|
+
deprecated: "deprecated";
|
|
145
|
+
}>>>;
|
|
146
|
+
sourceNodeId: z.ZodOptional<z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>>;
|
|
147
|
+
from: z.ZodOptional<z.ZodString>;
|
|
148
|
+
to: z.ZodOptional<z.ZodString>;
|
|
149
|
+
cardinality: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
150
|
+
optional: "optional";
|
|
151
|
+
one: "one";
|
|
152
|
+
many: "many";
|
|
153
|
+
}>>>;
|
|
154
|
+
on: z.ZodOptional<z.ZodString>;
|
|
155
|
+
implementedBy: z.ZodOptional<z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>>;
|
|
156
|
+
approval: z.ZodOptional<z.ZodBoolean>;
|
|
157
|
+
}, z.core.$strict>;
|
|
158
|
+
export type TypeUpdateInput = z.infer<typeof TypeUpdateInput>;
|
|
159
|
+
export declare const TypeArchiveInput: z.ZodObject<{
|
|
160
|
+
typeId: z.ZodTemplateLiteral<`type_${string}`>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
export type TypeArchiveInput = z.infer<typeof TypeArchiveInput>;
|
|
163
|
+
export declare const TypeRestoreInput: z.ZodObject<{
|
|
164
|
+
typeId: z.ZodTemplateLiteral<`type_${string}`>;
|
|
165
|
+
}, z.core.$strict>;
|
|
166
|
+
export type TypeRestoreInput = z.infer<typeof TypeRestoreInput>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idSchema } from "../ids/ids.js";
|
|
3
|
+
import { NodeId } from "../nodes/nodes.js";
|
|
4
|
+
import { IdempotencyKey, Rev } from "../primitives/primitives.js";
|
|
5
|
+
// The ontology's types (#1124, E250, Nodes › Ontologie): what something is (an object), what
|
|
6
|
+
// connects two things (a relation), what may change (an action) and who acts (an actor). Described
|
|
7
|
+
// per type, never per instance, and nothing has to be described: a type without description carries
|
|
8
|
+
// the name of where it comes from.
|
|
9
|
+
//
|
|
10
|
+
// Colab brings base types along, locked: every node has its kind as object type, every relation
|
|
11
|
+
// rule of `baseRelationTypes` is a relation type, people, machines and Colab itself are actor
|
|
12
|
+
// types, and creating, changing and archiving are the base actions of every type. A company adds
|
|
13
|
+
// its own types over them; an own object type stands on a source (a node, e.g. the table whose rows
|
|
14
|
+
// are its objects) or on none, a thing of the real world ("Monteur", "Schlüsselkasten").
|
|
15
|
+
export const typeKinds = ["object", "relation", "action", "actor"];
|
|
16
|
+
export const TypeKind = z.enum(typeKinds);
|
|
17
|
+
// Switched on per type: null is off.
|
|
18
|
+
export const typeStatuses = ["experimental", "active", "deprecated"];
|
|
19
|
+
export const TypeStatus = z.enum(typeStatuses);
|
|
20
|
+
// How many things a relation type connects on its far end: 1, 0..1, 0..n.
|
|
21
|
+
export const cardinalities = ["one", "optional", "many"];
|
|
22
|
+
export const Cardinality = z.enum(cardinalities);
|
|
23
|
+
// The locked base types, by word. A node's object type is its kind.
|
|
24
|
+
export const baseObjectTypes = [
|
|
25
|
+
"document",
|
|
26
|
+
"file",
|
|
27
|
+
"table",
|
|
28
|
+
"board",
|
|
29
|
+
"task",
|
|
30
|
+
"gadget",
|
|
31
|
+
"skill",
|
|
32
|
+
"goal",
|
|
33
|
+
"source",
|
|
34
|
+
];
|
|
35
|
+
export const baseActorTypes = ["person", "machine", "system"];
|
|
36
|
+
export const baseActionTypes = ["create", "update", "archive"];
|
|
37
|
+
export const TypeId = idSchema("type").describe("An own type's id, `type_…`.");
|
|
38
|
+
// A type as a relation, an action or a set relation names it: an own type's id, or a base type as
|
|
39
|
+
// `base:<word>` (`base:table`, `base:person`, `base:mentions`, `base:create`).
|
|
40
|
+
export const TypeRef = z
|
|
41
|
+
.string()
|
|
42
|
+
.regex(/^(base:[a-z]+|type_[0-9A-HJKMNP-TV-Z]{26})$/)
|
|
43
|
+
.describe("A type: an own type's id `type_…`, or a base type as `base:<word>`.");
|
|
44
|
+
export const baseRef = (word) => `base:${word}`;
|
|
45
|
+
export const OntologyType = z.object({
|
|
46
|
+
typeId: TypeRef,
|
|
47
|
+
kind: TypeKind,
|
|
48
|
+
// A base type is locked: it has no rev and changes with Colab, not with the company.
|
|
49
|
+
base: z.boolean(),
|
|
50
|
+
name: z.string(),
|
|
51
|
+
description: z.string(),
|
|
52
|
+
status: TypeStatus.nullable(),
|
|
53
|
+
// An object type: the node its objects are, or come from (rows of a table); null for a thing of
|
|
54
|
+
// the real world without a source, and for every base type.
|
|
55
|
+
sourceNodeId: NodeId.nullable(),
|
|
56
|
+
// A relation type: the rule "from type × to type → meaning" and how many it connects.
|
|
57
|
+
from: TypeRef.nullable(),
|
|
58
|
+
to: TypeRef.nullable(),
|
|
59
|
+
cardinality: Cardinality.nullable(),
|
|
60
|
+
// Where its relations come from: a base rule's source ("text", "field", …); null for a type whose
|
|
61
|
+
// relations are set.
|
|
62
|
+
arisesFrom: z.string().nullable(),
|
|
63
|
+
// An action type: the type it acts on, what carries it out in Colab (a gadget, a skill, a board),
|
|
64
|
+
// and whether a person has to approve it first.
|
|
65
|
+
on: TypeRef.nullable(),
|
|
66
|
+
implementedBy: NodeId.nullable(),
|
|
67
|
+
approval: z.boolean(),
|
|
68
|
+
rev: z.int().nullable(),
|
|
69
|
+
updatedAt: z.iso.datetime().nullable(),
|
|
70
|
+
});
|
|
71
|
+
export const TypeListInput = z.strictObject({
|
|
72
|
+
kind: TypeKind.optional().describe("Only the types of this kind; all four without it."),
|
|
73
|
+
});
|
|
74
|
+
export const TypeList = z.object({
|
|
75
|
+
items: z.array(OntologyType),
|
|
76
|
+
nextCursor: z.null(),
|
|
77
|
+
});
|
|
78
|
+
const name = z.string().trim().min(1).max(120);
|
|
79
|
+
const description = z.string().max(4000);
|
|
80
|
+
export const TypeCreateInput = z.strictObject({
|
|
81
|
+
kind: TypeKind.describe("object: what something is; relation: a rule that connects two types; action: what may change a type; actor: who acts."),
|
|
82
|
+
name: name.describe("The type's name, e.g. Unterkunft, Monteur, vermietet an."),
|
|
83
|
+
description: description.optional().describe("What the type means, for people and their AI."),
|
|
84
|
+
status: TypeStatus.optional(),
|
|
85
|
+
sourceNodeId: NodeId.optional().describe("An object type only: the node its objects are or come from, e.g. the table whose rows they are. Leave it out for a thing of the real world."),
|
|
86
|
+
from: TypeRef.optional().describe("A relation type only: the type it starts at."),
|
|
87
|
+
to: TypeRef.optional().describe("A relation type only: the type it leads to."),
|
|
88
|
+
cardinality: Cardinality.optional().describe("A relation type only: how many it connects at its far end (one, optional, many)."),
|
|
89
|
+
on: TypeRef.optional().describe("An action type only: the type it acts on."),
|
|
90
|
+
implementedBy: NodeId.optional().describe("An action type only: the gadget, skill or board that carries it out."),
|
|
91
|
+
approval: z
|
|
92
|
+
.boolean()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe("An action type only: true when a person has to approve it before it runs."),
|
|
95
|
+
idempotencyKey: IdempotencyKey,
|
|
96
|
+
});
|
|
97
|
+
export const TypeUpdateInput = z.strictObject({
|
|
98
|
+
typeId: TypeId,
|
|
99
|
+
rev: Rev,
|
|
100
|
+
name: name.optional(),
|
|
101
|
+
description: description.optional(),
|
|
102
|
+
status: TypeStatus.nullable().optional().describe("null switches the status off."),
|
|
103
|
+
sourceNodeId: NodeId.nullable().optional(),
|
|
104
|
+
from: TypeRef.optional(),
|
|
105
|
+
to: TypeRef.optional(),
|
|
106
|
+
cardinality: Cardinality.nullable().optional(),
|
|
107
|
+
on: TypeRef.optional(),
|
|
108
|
+
implementedBy: NodeId.nullable().optional(),
|
|
109
|
+
approval: z.boolean().optional(),
|
|
110
|
+
});
|
|
111
|
+
export const TypeArchiveInput = z.strictObject({ typeId: TypeId });
|
|
112
|
+
export const TypeRestoreInput = z.strictObject({ typeId: TypeId });
|
|
@@ -37,6 +37,8 @@ export declare const Changed: z.ZodObject<{
|
|
|
37
37
|
connectionId: z.ZodOptional<z.ZodTemplateLiteral<`connection_${string}`>>;
|
|
38
38
|
credentialId: z.ZodOptional<z.ZodTemplateLiteral<`credential_${string}`>>;
|
|
39
39
|
mcpId: z.ZodOptional<z.ZodTemplateLiteral<`mcp_${string}`>>;
|
|
40
|
+
typeId: z.ZodOptional<z.ZodTemplateLiteral<`type_${string}`>>;
|
|
41
|
+
relationId: z.ZodOptional<z.ZodTemplateLiteral<`relation_${string}`>>;
|
|
40
42
|
ref: z.ZodOptional<z.ZodString>;
|
|
41
43
|
rev: z.ZodOptional<z.ZodNumber>;
|
|
42
44
|
version: z.ZodOptional<z.ZodNumber>;
|
|
@@ -171,6 +173,8 @@ export declare const Written: z.ZodObject<{
|
|
|
171
173
|
connectionId: z.ZodOptional<z.ZodTemplateLiteral<`connection_${string}`>>;
|
|
172
174
|
credentialId: z.ZodOptional<z.ZodTemplateLiteral<`credential_${string}`>>;
|
|
173
175
|
mcpId: z.ZodOptional<z.ZodTemplateLiteral<`mcp_${string}`>>;
|
|
176
|
+
typeId: z.ZodOptional<z.ZodTemplateLiteral<`type_${string}`>>;
|
|
177
|
+
relationId: z.ZodOptional<z.ZodTemplateLiteral<`relation_${string}`>>;
|
|
174
178
|
ref: z.ZodOptional<z.ZodString>;
|
|
175
179
|
rev: z.ZodOptional<z.ZodNumber>;
|
|
176
180
|
version: z.ZodOptional<z.ZodNumber>;
|
package/dist/written/written.js
CHANGED
|
@@ -14,11 +14,13 @@ import { Missing, Reached } from "../missing/missing.js";
|
|
|
14
14
|
import { NodeId, NodeReader } from "../nodes/nodes.js";
|
|
15
15
|
import { CredentialId } from "../operators/operators.js";
|
|
16
16
|
import { ProviderId } from "../providers/providers.js";
|
|
17
|
+
import { RelationId } from "../relations/relations.js";
|
|
17
18
|
import { RoleId } from "../roles/roles.js";
|
|
18
19
|
import { RunId } from "../runs/runs.js";
|
|
19
20
|
import { FunctionId, InterfaceId, ServiceId } from "../services/services.js";
|
|
20
21
|
import { QueryId } from "../sources/sources.js";
|
|
21
22
|
import { MemberId, TeamId } from "../teams/teams.js";
|
|
23
|
+
import { TypeId } from "../types/types.js";
|
|
22
24
|
import { UserId } from "../users/users.js";
|
|
23
25
|
// What a write answers over `/mcp` (E126, #672): what it changed and what that caused, never the
|
|
24
26
|
// object it wrote. The AI sent the object itself; echoing it back filled an Operator's context with
|
|
@@ -67,6 +69,9 @@ export const Changed = z.object({
|
|
|
67
69
|
credentialId: CredentialId.optional(),
|
|
68
70
|
// A person's own MCP (#802).
|
|
69
71
|
mcpId: McpId.optional(),
|
|
72
|
+
// The ontology (#1124): an own type and a relation somebody set.
|
|
73
|
+
typeId: TypeId.optional(),
|
|
74
|
+
relationId: RelationId.optional(),
|
|
70
75
|
// The caller's own name for an entry of a create of many (#625).
|
|
71
76
|
ref: z.string().optional(),
|
|
72
77
|
rev: z.number().int().optional(),
|
package/package.json
CHANGED