at-shared-types 1.2.5 → 1.2.7
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/ai/protocol/ids.d.ts +0 -10
- package/dist/ai/protocol/ids.d.ts.map +1 -1
- package/dist/protocol.cjs +12 -20
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.ts +70 -31
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.mjs +11 -19
- package/dist/protocol.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -4,24 +4,14 @@ type Brand<T, B extends string> = T & {
|
|
|
4
4
|
export type ATAICapabilityID = Brand<string, "ATAICapabilityID">;
|
|
5
5
|
export type ATAIPromptID = Brand<string, "ATAIPromptID">;
|
|
6
6
|
export declare const ATAIID: {
|
|
7
|
-
/** Validate & brand an existing capability id (throws if invalid). */
|
|
8
7
|
readonly validateCapability: (id: string) => ATAICapabilityID;
|
|
9
|
-
/** Validate & brand an existing prompt id (throws if invalid). */
|
|
10
8
|
readonly validatePrompt: (id: string) => ATAIPromptID;
|
|
11
|
-
/**
|
|
12
|
-
* Build a capability id from parts (then validates & brands).
|
|
13
|
-
* Format: cap.<app>.<area>.<object>.<verb>
|
|
14
|
-
*/
|
|
15
9
|
readonly makeCapability: (parts: {
|
|
16
10
|
app: string;
|
|
17
11
|
area: string;
|
|
18
12
|
target: string;
|
|
19
13
|
action: string;
|
|
20
14
|
}) => ATAICapabilityID;
|
|
21
|
-
/**
|
|
22
|
-
* Build a prompt id from parts (then validates & brands).
|
|
23
|
-
* Format: prompt.<app>.<area>.<object>.<verb>.v<major>
|
|
24
|
-
*/
|
|
25
15
|
readonly makePrompt: (parts: {
|
|
26
16
|
app: string;
|
|
27
17
|
area: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/ai/protocol/ids.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/ai/protocol/ids.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAuCzD,eAAO,MAAM,MAAM;sCACQ,MAAM,KAAG,gBAAgB;kCAK7B,MAAM,KAAG,YAAY;qCAKlB;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAClB,KAAG,gBAAgB;iCAKF;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,EAAE,MAAM,CAAC;KACb,KAAG,YAAY;CAKV,CAAC"}
|
package/dist/protocol.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/protocol.ts
|
|
21
21
|
var protocol_exports = {};
|
|
22
22
|
__export(protocol_exports, {
|
|
23
|
-
|
|
23
|
+
ATAI: () => ATAI,
|
|
24
24
|
ATAPIErrorCodeMap: () => ATAPIErrorCodeMap,
|
|
25
25
|
ATProtocol: () => ATProtocol
|
|
26
26
|
});
|
|
@@ -34,9 +34,10 @@ var ATAPIErrorCodeMap = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
// src/ai/protocol/ids.ts
|
|
37
|
+
var SEG = `[a-z0-9_]+`;
|
|
37
38
|
var RX = {
|
|
38
|
-
capability:
|
|
39
|
-
prompt:
|
|
39
|
+
capability: new RegExp(`^cap\\.${SEG}(?:\\.${SEG}){3,}$`, "i"),
|
|
40
|
+
prompt: new RegExp(`^prompt\\.${SEG}(?:\\.${SEG}){3,}\\.v[0-9]+$`, "i")
|
|
40
41
|
};
|
|
41
42
|
function validate(kind, id) {
|
|
42
43
|
if (!RX[kind].test(id)) {
|
|
@@ -44,34 +45,24 @@ function validate(kind, id) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
function normalizeSegment(seg) {
|
|
47
|
-
return seg.trim().toLowerCase().replace(/[\
|
|
48
|
+
return seg.trim().toLowerCase().replace(/[\s-]+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
48
49
|
}
|
|
49
50
|
function joinSegments(...segs) {
|
|
50
51
|
return segs.map(normalizeSegment).filter(Boolean).join(".");
|
|
51
52
|
}
|
|
52
53
|
var ATAIID = {
|
|
53
|
-
/** Validate & brand an existing capability id (throws if invalid). */
|
|
54
54
|
validateCapability(id) {
|
|
55
55
|
validate("capability", id);
|
|
56
56
|
return id;
|
|
57
57
|
},
|
|
58
|
-
/** Validate & brand an existing prompt id (throws if invalid). */
|
|
59
58
|
validatePrompt(id) {
|
|
60
59
|
validate("prompt", id);
|
|
61
60
|
return id;
|
|
62
61
|
},
|
|
63
|
-
/**
|
|
64
|
-
* Build a capability id from parts (then validates & brands).
|
|
65
|
-
* Format: cap.<app>.<area>.<object>.<verb>
|
|
66
|
-
*/
|
|
67
62
|
makeCapability(parts) {
|
|
68
63
|
const id = `cap.${joinSegments(parts.app, parts.area, parts.target, parts.action)}`;
|
|
69
64
|
return ATAIID.validateCapability(id);
|
|
70
65
|
},
|
|
71
|
-
/**
|
|
72
|
-
* Build a prompt id from parts (then validates & brands).
|
|
73
|
-
* Format: prompt.<app>.<area>.<object>.<verb>.v<major>
|
|
74
|
-
*/
|
|
75
66
|
makePrompt(parts) {
|
|
76
67
|
const major = Math.max(0, Math.floor(parts.v));
|
|
77
68
|
const id = `prompt.${joinSegments(parts.app, parts.area, parts.target, parts.action)}.v${major}`;
|
|
@@ -135,17 +126,18 @@ var ATAICapabilities = {
|
|
|
135
126
|
};
|
|
136
127
|
|
|
137
128
|
// src/protocol.ts
|
|
129
|
+
var ATAI = {
|
|
130
|
+
ID: ATAIID,
|
|
131
|
+
Prompts: ATAIPrompts,
|
|
132
|
+
Capabilities: ATAICapabilities
|
|
133
|
+
};
|
|
138
134
|
var ATProtocol = {
|
|
139
135
|
ATAPIErrorCodeMap,
|
|
140
|
-
|
|
141
|
-
ai: ATAIID
|
|
142
|
-
},
|
|
143
|
-
ATAIPrompts,
|
|
144
|
-
ATAICapabilities
|
|
136
|
+
AI: ATAI
|
|
145
137
|
};
|
|
146
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
139
|
0 && (module.exports = {
|
|
148
|
-
|
|
140
|
+
ATAI,
|
|
149
141
|
ATAPIErrorCodeMap,
|
|
150
142
|
ATProtocol
|
|
151
143
|
});
|
package/dist/protocol.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/protocol.ts","../src/core/protocol/errors.ts","../src/ai/protocol/ids.ts","../src/ai/protocol/prompts.ts","../src/ai/protocol/capabilities.ts"],"sourcesContent":["export * from \"./core/protocol/errors\";\r\
|
|
1
|
+
{"version":3,"sources":["../src/protocol.ts","../src/core/protocol/errors.ts","../src/ai/protocol/ids.ts","../src/ai/protocol/prompts.ts","../src/ai/protocol/capabilities.ts"],"sourcesContent":["export * from \"./core/protocol/errors\";\r\n\r\nimport { ATAPIErrorCodeMap } from \"./core/protocol/errors\";\r\n\r\nimport { ATAIID } from \"./ai/protocol/ids\";\r\nimport { ATAIPrompts } from \"./ai/protocol/prompts\";\r\nimport { ATAICapabilities } from \"./ai/protocol/capabilities\";\r\n\r\nexport const ATAI = {\r\n ID: ATAIID,\r\n Prompts: ATAIPrompts,\r\n Capabilities: ATAICapabilities,\r\n} as const;\r\n\r\nexport const ATProtocol = {\r\n ATAPIErrorCodeMap,\r\n AI: ATAI,\r\n} as const;\r\n\r\nexport type ATAICapabilityID =\r\n import(\"./ai/protocol/ids\").ATAICapabilityID;\r\nexport type ATAIPromptID =\r\n import(\"./ai/protocol/ids\").ATAIPromptID;\r\n\r\nexport type ATAPIErrorCode =\r\n import(\"./core/protocol/errors\").ATAPIErrorCode;\r\n","export const ATAPIErrorCodeMap = {\r\n AI_SESSION_EXPIRED: 4501,\r\n AI_SESSION_NOT_FOUND: 4502,\r\n AI_REQUEST_CONTEXT_MISSING: 4503,\r\n} as const;\r\n\r\nexport type ATAPIErrorCode = typeof ATAPIErrorCodeMap[keyof typeof ATAPIErrorCodeMap];\r\n","type Brand<T, B extends string> = T & { readonly __brand: B };\r\n\r\nexport type ATAICapabilityID = Brand<string, \"ATAICapabilityID\">;\r\nexport type ATAIPromptID = Brand<string, \"ATAIPromptID\">;\r\n\r\n// allow underscores inside each segment\r\nconst SEG = `[a-z0-9_]+`;\r\n\r\nconst RX = {\r\n capability: new RegExp(`^cap\\\\.${SEG}(?:\\\\.${SEG}){3,}$`, \"i\"),\r\n prompt: new RegExp(`^prompt\\\\.${SEG}(?:\\\\.${SEG}){3,}\\\\.v[0-9]+$`, \"i\"),\r\n} as const;\r\n\r\nfunction validate(kind: keyof typeof RX, id: string): void {\r\n if (!RX[kind].test(id)) {\r\n throw new Error(`[AI-PROTOCOL] Invalid ${kind} id: \"${id}\"`);\r\n }\r\n}\r\n\r\n/**\r\n * Normalize a segment for IDs (snake_case).\r\n * - trims\r\n * - lowercases\r\n * - converts spaces and dashes to underscores\r\n * - removes illegal chars (keeps a-z0-9 and _)\r\n * - collapses multiple underscores\r\n * - trims leading/trailing underscores\r\n */\r\nfunction normalizeSegment(seg: string): string {\r\n return seg\r\n .trim()\r\n .toLowerCase()\r\n .replace(/[\\s-]+/g, \"_\") // spaces/dashes -> _\r\n .replace(/[^a-z0-9_]/g, \"\") // keep only a-z0-9_\r\n .replace(/_+/g, \"_\") // collapse __\r\n .replace(/^_+|_+$/g, \"\"); // trim edges\r\n}\r\n\r\nfunction joinSegments(...segs: string[]): string {\r\n return segs.map(normalizeSegment).filter(Boolean).join(\".\");\r\n}\r\n\r\nexport const ATAIID = {\r\n validateCapability(id: string): ATAICapabilityID {\r\n validate(\"capability\", id);\r\n return id as ATAICapabilityID;\r\n },\r\n\r\n validatePrompt(id: string): ATAIPromptID {\r\n validate(\"prompt\", id);\r\n return id as ATAIPromptID;\r\n },\r\n\r\n makeCapability(parts: {\r\n app: string;\r\n area: string;\r\n target: string;\r\n action: string;\r\n }): ATAICapabilityID {\r\n const id = `cap.${joinSegments(parts.app, parts.area, parts.target, parts.action)}`;\r\n return ATAIID.validateCapability(id);\r\n },\r\n\r\n makePrompt(parts: {\r\n app: string;\r\n area: string;\r\n target: string;\r\n action: string;\r\n v: number;\r\n }): ATAIPromptID {\r\n const major = Math.max(0, Math.floor(parts.v));\r\n const id = `prompt.${joinSegments(parts.app, parts.area, parts.target, parts.action)}.v${major}`;\r\n return ATAIID.validatePrompt(id);\r\n },\r\n} as const;\r\n","import { ATAIID } from \"./ids\";\r\n\r\nexport const ATAIPrompts = {\r\n BPMS: {\r\n SYSTEM: {\r\n INTENT_DETECTION_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"system\",\r\n target: \"intent\",\r\n action: \"detection\",\r\n v: 1\r\n }),\r\n },\r\n FORMAKER: {\r\n VALUE_GENERATE_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"formmaker\",\r\n target: \"value\",\r\n action: \"generate\",\r\n v: 1,\r\n }),\r\n },\r\n APIMANAGER: {\r\n POST_RESPONSE_SCRIPT_GENERATE_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"apimanager\",\r\n target: \"post_response_script\",\r\n action: \"generate\",\r\n v: 1,\r\n }),\r\n },\r\n },\r\n} as const;\r\n","import { ATAIID } from \"./ids\";\r\n\r\nexport const ATAICapabilities = {\r\n BPMS: {\r\n FORMAKER: {\r\n FORM_GENERATE: ATAIID.makeCapability({\r\n app: \"bpms\",\r\n area: \"formmaker\",\r\n target: \"form\",\r\n action: \"generate\",\r\n }),\r\n },\r\n APIMANAGER: {\r\n POST_RESPONSE_SCRIPT_GENERATE: ATAIID.makeCapability({\r\n app: \"bpms\",\r\n area: \"apimanager\",\r\n target: \"post_response_script\",\r\n action: \"generate\",\r\n }),\r\n },\r\n },\r\n} as const;\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,oBAAoB;AAAA,EAC7B,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,4BAA4B;AAChC;;;ACEA,IAAM,MAAM;AAEZ,IAAM,KAAK;AAAA,EACP,YAAY,IAAI,OAAO,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG;AAAA,EAC7D,QAAQ,IAAI,OAAO,aAAa,GAAG,SAAS,GAAG,oBAAoB,GAAG;AAC1E;AAEA,SAAS,SAAS,MAAuB,IAAkB;AACvD,MAAI,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG;AACpB,UAAM,IAAI,MAAM,yBAAyB,IAAI,SAAS,EAAE,GAAG;AAAA,EAC/D;AACJ;AAWA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IACF,KAAK,EACL,YAAY,EACZ,QAAQ,WAAW,GAAG,EACtB,QAAQ,eAAe,EAAE,EACzB,QAAQ,OAAO,GAAG,E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,EACJ;AACJ;;;AC9BO,IAAM,mBAAmB;AAAA,EAC5B,MAAM;AAAA,IACF,UAAU;AAAA,MACN,eAAe,OAAO,eAAe;AAAA,QACjC,KAAK;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA,MACZ,CAAC;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACR,+BAA+B,OAAO,eAAe;AAAA,QACjD,KAAK;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA,MACZ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;;;AJbO,IAAM,OAAO;AAAA,EAChB,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,cAAc;AAClB;AAEO,IAAM,aAAa;AAAA,EACtB;AAAA,EACA,IAAI;AACR;","names":[]}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,57 +1,96 @@
|
|
|
1
1
|
export * from "./core/protocol/errors";
|
|
2
|
-
export
|
|
2
|
+
export declare const ATAI: {
|
|
3
|
+
readonly ID: {
|
|
4
|
+
readonly validateCapability: (id: string) => import("./ai/protocol/ids").ATAICapabilityID;
|
|
5
|
+
readonly validatePrompt: (id: string) => import("./ai/protocol/ids").ATAIPromptID;
|
|
6
|
+
readonly makeCapability: (parts: {
|
|
7
|
+
app: string;
|
|
8
|
+
area: string;
|
|
9
|
+
target: string;
|
|
10
|
+
action: string;
|
|
11
|
+
}) => import("./ai/protocol/ids").ATAICapabilityID;
|
|
12
|
+
readonly makePrompt: (parts: {
|
|
13
|
+
app: string;
|
|
14
|
+
area: string;
|
|
15
|
+
target: string;
|
|
16
|
+
action: string;
|
|
17
|
+
v: number;
|
|
18
|
+
}) => import("./ai/protocol/ids").ATAIPromptID;
|
|
19
|
+
};
|
|
20
|
+
readonly Prompts: {
|
|
21
|
+
readonly BPMS: {
|
|
22
|
+
readonly SYSTEM: {
|
|
23
|
+
readonly INTENT_DETECTION_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
24
|
+
};
|
|
25
|
+
readonly FORMAKER: {
|
|
26
|
+
readonly VALUE_GENERATE_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
27
|
+
};
|
|
28
|
+
readonly APIMANAGER: {
|
|
29
|
+
readonly POST_RESPONSE_SCRIPT_GENERATE_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly Capabilities: {
|
|
34
|
+
readonly BPMS: {
|
|
35
|
+
readonly FORMAKER: {
|
|
36
|
+
readonly FORM_GENERATE: import("./ai/protocol/ids").ATAICapabilityID;
|
|
37
|
+
};
|
|
38
|
+
readonly APIMANAGER: {
|
|
39
|
+
readonly POST_RESPONSE_SCRIPT_GENERATE: import("./ai/protocol/ids").ATAICapabilityID;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
3
44
|
export declare const ATProtocol: {
|
|
4
45
|
readonly ATAPIErrorCodeMap: {
|
|
5
46
|
readonly AI_SESSION_EXPIRED: 4501;
|
|
6
47
|
readonly AI_SESSION_NOT_FOUND: 4502;
|
|
7
48
|
readonly AI_REQUEST_CONTEXT_MISSING: 4503;
|
|
8
49
|
};
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
11
|
-
readonly validateCapability: (id: string) => import("./protocol").ATAICapabilityID;
|
|
12
|
-
readonly validatePrompt: (id: string) => import("./protocol").ATAIPromptID;
|
|
50
|
+
readonly AI: {
|
|
51
|
+
readonly ID: {
|
|
52
|
+
readonly validateCapability: (id: string) => import("./ai/protocol/ids").ATAICapabilityID;
|
|
53
|
+
readonly validatePrompt: (id: string) => import("./ai/protocol/ids").ATAIPromptID;
|
|
13
54
|
readonly makeCapability: (parts: {
|
|
14
55
|
app: string;
|
|
15
56
|
area: string;
|
|
16
57
|
target: string;
|
|
17
58
|
action: string;
|
|
18
|
-
}) => import("./protocol").ATAICapabilityID;
|
|
59
|
+
}) => import("./ai/protocol/ids").ATAICapabilityID;
|
|
19
60
|
readonly makePrompt: (parts: {
|
|
20
61
|
app: string;
|
|
21
62
|
area: string;
|
|
22
63
|
target: string;
|
|
23
64
|
action: string;
|
|
24
65
|
v: number;
|
|
25
|
-
}) => import("./protocol").ATAIPromptID;
|
|
66
|
+
}) => import("./ai/protocol/ids").ATAIPromptID;
|
|
26
67
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
readonly Prompts: {
|
|
69
|
+
readonly BPMS: {
|
|
70
|
+
readonly SYSTEM: {
|
|
71
|
+
readonly INTENT_DETECTION_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
72
|
+
};
|
|
73
|
+
readonly FORMAKER: {
|
|
74
|
+
readonly VALUE_GENERATE_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
75
|
+
};
|
|
76
|
+
readonly APIMANAGER: {
|
|
77
|
+
readonly POST_RESPONSE_SCRIPT_GENERATE_V1: import("./ai/protocol/ids").ATAIPromptID;
|
|
78
|
+
};
|
|
38
79
|
};
|
|
39
80
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
readonly Capabilities: {
|
|
82
|
+
readonly BPMS: {
|
|
83
|
+
readonly FORMAKER: {
|
|
84
|
+
readonly FORM_GENERATE: import("./ai/protocol/ids").ATAICapabilityID;
|
|
85
|
+
};
|
|
86
|
+
readonly APIMANAGER: {
|
|
87
|
+
readonly POST_RESPONSE_SCRIPT_GENERATE: import("./ai/protocol/ids").ATAICapabilityID;
|
|
88
|
+
};
|
|
48
89
|
};
|
|
49
90
|
};
|
|
50
91
|
};
|
|
51
92
|
};
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type ATAIPromptID = import("./ai/protocol/ids").ATAIPromptID;
|
|
56
|
-
}
|
|
93
|
+
export type ATAICapabilityID = import("./ai/protocol/ids").ATAICapabilityID;
|
|
94
|
+
export type ATAIPromptID = import("./ai/protocol/ids").ATAIPromptID;
|
|
95
|
+
export type ATAPIErrorCode = import("./core/protocol/errors").ATAPIErrorCode;
|
|
57
96
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AAQvC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIP,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGb,CAAC;AAEX,MAAM,MAAM,gBAAgB,GACxB,OAAO,mBAAmB,EAAE,gBAAgB,CAAC;AACjD,MAAM,MAAM,YAAY,GACpB,OAAO,mBAAmB,EAAE,YAAY,CAAC;AAE7C,MAAM,MAAM,cAAc,GACtB,OAAO,wBAAwB,EAAE,cAAc,CAAC"}
|
package/dist/protocol.mjs
CHANGED
|
@@ -8,9 +8,10 @@ var ATAPIErrorCodeMap = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// src/ai/protocol/ids.ts
|
|
11
|
+
var SEG = `[a-z0-9_]+`;
|
|
11
12
|
var RX = {
|
|
12
|
-
capability:
|
|
13
|
-
prompt:
|
|
13
|
+
capability: new RegExp(`^cap\\.${SEG}(?:\\.${SEG}){3,}$`, "i"),
|
|
14
|
+
prompt: new RegExp(`^prompt\\.${SEG}(?:\\.${SEG}){3,}\\.v[0-9]+$`, "i")
|
|
14
15
|
};
|
|
15
16
|
function validate(kind, id) {
|
|
16
17
|
if (!RX[kind].test(id)) {
|
|
@@ -18,34 +19,24 @@ function validate(kind, id) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
function normalizeSegment(seg) {
|
|
21
|
-
return seg.trim().toLowerCase().replace(/[\
|
|
22
|
+
return seg.trim().toLowerCase().replace(/[\s-]+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
22
23
|
}
|
|
23
24
|
function joinSegments(...segs) {
|
|
24
25
|
return segs.map(normalizeSegment).filter(Boolean).join(".");
|
|
25
26
|
}
|
|
26
27
|
var ATAIID = {
|
|
27
|
-
/** Validate & brand an existing capability id (throws if invalid). */
|
|
28
28
|
validateCapability(id) {
|
|
29
29
|
validate("capability", id);
|
|
30
30
|
return id;
|
|
31
31
|
},
|
|
32
|
-
/** Validate & brand an existing prompt id (throws if invalid). */
|
|
33
32
|
validatePrompt(id) {
|
|
34
33
|
validate("prompt", id);
|
|
35
34
|
return id;
|
|
36
35
|
},
|
|
37
|
-
/**
|
|
38
|
-
* Build a capability id from parts (then validates & brands).
|
|
39
|
-
* Format: cap.<app>.<area>.<object>.<verb>
|
|
40
|
-
*/
|
|
41
36
|
makeCapability(parts) {
|
|
42
37
|
const id = `cap.${joinSegments(parts.app, parts.area, parts.target, parts.action)}`;
|
|
43
38
|
return ATAIID.validateCapability(id);
|
|
44
39
|
},
|
|
45
|
-
/**
|
|
46
|
-
* Build a prompt id from parts (then validates & brands).
|
|
47
|
-
* Format: prompt.<app>.<area>.<object>.<verb>.v<major>
|
|
48
|
-
*/
|
|
49
40
|
makePrompt(parts) {
|
|
50
41
|
const major = Math.max(0, Math.floor(parts.v));
|
|
51
42
|
const id = `prompt.${joinSegments(parts.app, parts.area, parts.target, parts.action)}.v${major}`;
|
|
@@ -109,16 +100,17 @@ var ATAICapabilities = {
|
|
|
109
100
|
};
|
|
110
101
|
|
|
111
102
|
// src/protocol.ts
|
|
103
|
+
var ATAI = {
|
|
104
|
+
ID: ATAIID,
|
|
105
|
+
Prompts: ATAIPrompts,
|
|
106
|
+
Capabilities: ATAICapabilities
|
|
107
|
+
};
|
|
112
108
|
var ATProtocol = {
|
|
113
109
|
ATAPIErrorCodeMap,
|
|
114
|
-
|
|
115
|
-
ai: ATAIID
|
|
116
|
-
},
|
|
117
|
-
ATAIPrompts,
|
|
118
|
-
ATAICapabilities
|
|
110
|
+
AI: ATAI
|
|
119
111
|
};
|
|
120
112
|
export {
|
|
121
|
-
|
|
113
|
+
ATAI,
|
|
122
114
|
ATAPIErrorCodeMap,
|
|
123
115
|
ATProtocol
|
|
124
116
|
};
|
package/dist/protocol.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/protocol/errors.ts","../src/ai/protocol/ids.ts","../src/ai/protocol/prompts.ts","../src/ai/protocol/capabilities.ts","../src/protocol.ts"],"sourcesContent":["export const ATAPIErrorCodeMap = {\r\n AI_SESSION_EXPIRED: 4501,\r\n AI_SESSION_NOT_FOUND: 4502,\r\n AI_REQUEST_CONTEXT_MISSING: 4503,\r\n} as const;\r\n\r\nexport type ATAPIErrorCode = typeof ATAPIErrorCodeMap[keyof typeof ATAPIErrorCodeMap];\r\n","type Brand<T, B extends string> = T & { readonly __brand: B };\r\n\r\nexport type ATAICapabilityID = Brand<string, \"ATAICapabilityID\">;\r\nexport type ATAIPromptID = Brand<string, \"ATAIPromptID\">;\r\n\r\nconst RX = {\r\n capability:
|
|
1
|
+
{"version":3,"sources":["../src/core/protocol/errors.ts","../src/ai/protocol/ids.ts","../src/ai/protocol/prompts.ts","../src/ai/protocol/capabilities.ts","../src/protocol.ts"],"sourcesContent":["export const ATAPIErrorCodeMap = {\r\n AI_SESSION_EXPIRED: 4501,\r\n AI_SESSION_NOT_FOUND: 4502,\r\n AI_REQUEST_CONTEXT_MISSING: 4503,\r\n} as const;\r\n\r\nexport type ATAPIErrorCode = typeof ATAPIErrorCodeMap[keyof typeof ATAPIErrorCodeMap];\r\n","type Brand<T, B extends string> = T & { readonly __brand: B };\r\n\r\nexport type ATAICapabilityID = Brand<string, \"ATAICapabilityID\">;\r\nexport type ATAIPromptID = Brand<string, \"ATAIPromptID\">;\r\n\r\n// allow underscores inside each segment\r\nconst SEG = `[a-z0-9_]+`;\r\n\r\nconst RX = {\r\n capability: new RegExp(`^cap\\\\.${SEG}(?:\\\\.${SEG}){3,}$`, \"i\"),\r\n prompt: new RegExp(`^prompt\\\\.${SEG}(?:\\\\.${SEG}){3,}\\\\.v[0-9]+$`, \"i\"),\r\n} as const;\r\n\r\nfunction validate(kind: keyof typeof RX, id: string): void {\r\n if (!RX[kind].test(id)) {\r\n throw new Error(`[AI-PROTOCOL] Invalid ${kind} id: \"${id}\"`);\r\n }\r\n}\r\n\r\n/**\r\n * Normalize a segment for IDs (snake_case).\r\n * - trims\r\n * - lowercases\r\n * - converts spaces and dashes to underscores\r\n * - removes illegal chars (keeps a-z0-9 and _)\r\n * - collapses multiple underscores\r\n * - trims leading/trailing underscores\r\n */\r\nfunction normalizeSegment(seg: string): string {\r\n return seg\r\n .trim()\r\n .toLowerCase()\r\n .replace(/[\\s-]+/g, \"_\") // spaces/dashes -> _\r\n .replace(/[^a-z0-9_]/g, \"\") // keep only a-z0-9_\r\n .replace(/_+/g, \"_\") // collapse __\r\n .replace(/^_+|_+$/g, \"\"); // trim edges\r\n}\r\n\r\nfunction joinSegments(...segs: string[]): string {\r\n return segs.map(normalizeSegment).filter(Boolean).join(\".\");\r\n}\r\n\r\nexport const ATAIID = {\r\n validateCapability(id: string): ATAICapabilityID {\r\n validate(\"capability\", id);\r\n return id as ATAICapabilityID;\r\n },\r\n\r\n validatePrompt(id: string): ATAIPromptID {\r\n validate(\"prompt\", id);\r\n return id as ATAIPromptID;\r\n },\r\n\r\n makeCapability(parts: {\r\n app: string;\r\n area: string;\r\n target: string;\r\n action: string;\r\n }): ATAICapabilityID {\r\n const id = `cap.${joinSegments(parts.app, parts.area, parts.target, parts.action)}`;\r\n return ATAIID.validateCapability(id);\r\n },\r\n\r\n makePrompt(parts: {\r\n app: string;\r\n area: string;\r\n target: string;\r\n action: string;\r\n v: number;\r\n }): ATAIPromptID {\r\n const major = Math.max(0, Math.floor(parts.v));\r\n const id = `prompt.${joinSegments(parts.app, parts.area, parts.target, parts.action)}.v${major}`;\r\n return ATAIID.validatePrompt(id);\r\n },\r\n} as const;\r\n","import { ATAIID } from \"./ids\";\r\n\r\nexport const ATAIPrompts = {\r\n BPMS: {\r\n SYSTEM: {\r\n INTENT_DETECTION_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"system\",\r\n target: \"intent\",\r\n action: \"detection\",\r\n v: 1\r\n }),\r\n },\r\n FORMAKER: {\r\n VALUE_GENERATE_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"formmaker\",\r\n target: \"value\",\r\n action: \"generate\",\r\n v: 1,\r\n }),\r\n },\r\n APIMANAGER: {\r\n POST_RESPONSE_SCRIPT_GENERATE_V1: ATAIID.makePrompt({\r\n app: \"bpms\",\r\n area: \"apimanager\",\r\n target: \"post_response_script\",\r\n action: \"generate\",\r\n v: 1,\r\n }),\r\n },\r\n },\r\n} as const;\r\n","import { ATAIID } from \"./ids\";\r\n\r\nexport const ATAICapabilities = {\r\n BPMS: {\r\n FORMAKER: {\r\n FORM_GENERATE: ATAIID.makeCapability({\r\n app: \"bpms\",\r\n area: \"formmaker\",\r\n target: \"form\",\r\n action: \"generate\",\r\n }),\r\n },\r\n APIMANAGER: {\r\n POST_RESPONSE_SCRIPT_GENERATE: ATAIID.makeCapability({\r\n app: \"bpms\",\r\n area: \"apimanager\",\r\n target: \"post_response_script\",\r\n action: \"generate\",\r\n }),\r\n },\r\n },\r\n} as const;\r\n","export * from \"./core/protocol/errors\";\r\n\r\nimport { ATAPIErrorCodeMap } from \"./core/protocol/errors\";\r\n\r\nimport { ATAIID } from \"./ai/protocol/ids\";\r\nimport { ATAIPrompts } from \"./ai/protocol/prompts\";\r\nimport { ATAICapabilities } from \"./ai/protocol/capabilities\";\r\n\r\nexport const ATAI = {\r\n ID: ATAIID,\r\n Prompts: ATAIPrompts,\r\n Capabilities: ATAICapabilities,\r\n} as const;\r\n\r\nexport const ATProtocol = {\r\n ATAPIErrorCodeMap,\r\n AI: ATAI,\r\n} as const;\r\n\r\nexport type ATAICapabilityID =\r\n import(\"./ai/protocol/ids\").ATAICapabilityID;\r\nexport type ATAIPromptID =\r\n import(\"./ai/protocol/ids\").ATAIPromptID;\r\n\r\nexport type ATAPIErrorCode =\r\n import(\"./core/protocol/errors\").ATAPIErrorCode;\r\n"],"mappings":";;;AAAO,IAAM,oBAAoB;AAAA,EAC7B,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,4BAA4B;AAChC;;;ACEA,IAAM,MAAM;AAEZ,IAAM,KAAK;AAAA,EACP,YAAY,IAAI,OAAO,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG;AAAA,EAC7D,QAAQ,IAAI,OAAO,aAAa,GAAG,SAAS,GAAG,oBAAoB,GAAG;AAC1E;AAEA,SAAS,SAAS,MAAuB,IAAkB;AACvD,MAAI,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG;AACpB,UAAM,IAAI,MAAM,yBAAyB,IAAI,SAAS,EAAE,GAAG;AAAA,EAC/D;AACJ;AAWA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IACF,KAAK,EACL,YAAY,EACZ,QAAQ,WAAW,GAAG,EACtB,QAAQ,eAAe,EAAE,EACzB,QAAQ,OAAO,GAAG,EAClB,QAAQ,YAAY,EAAE;AAC/B;AAEA,SAAS,gBAAgB,MAAwB;AAC7C,SAAO,KAAK,IAAI,gBAAgB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC9D;AAEO,IAAM,SAAS;AAAA,EAClB,mBAAmB,IAA8B;AAC7C,aAAS,cAAc,EAAE;AACzB,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