aacp-ts 1.1.0

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.
Files changed (49) hide show
  1. package/README.md +122 -0
  2. package/Src/decoder.ts +131 -0
  3. package/Src/encoders/ruleBasedEncoder.ts +140 -0
  4. package/Src/encoders/workflows/contractEncoder.ts +68 -0
  5. package/Src/encoders/workflows/invoiceEncoder.ts +71 -0
  6. package/Src/encoders/workflows/itEncoder.ts +95 -0
  7. package/Src/encoders/workflows/payrollEncoder.ts +110 -0
  8. package/Src/index.ts +27 -0
  9. package/Src/schema.ts +107 -0
  10. package/Src/validator.ts +127 -0
  11. package/dist/decoder.d.ts +12 -0
  12. package/dist/decoder.d.ts.map +1 -0
  13. package/dist/decoder.js +124 -0
  14. package/dist/decoder.js.map +1 -0
  15. package/dist/encoders/ruleBasedEncoder.d.ts +12 -0
  16. package/dist/encoders/ruleBasedEncoder.d.ts.map +1 -0
  17. package/dist/encoders/ruleBasedEncoder.js +113 -0
  18. package/dist/encoders/ruleBasedEncoder.js.map +1 -0
  19. package/dist/encoders/workflows/contractEncoder.d.ts +13 -0
  20. package/dist/encoders/workflows/contractEncoder.d.ts.map +1 -0
  21. package/dist/encoders/workflows/contractEncoder.js +43 -0
  22. package/dist/encoders/workflows/contractEncoder.js.map +1 -0
  23. package/dist/encoders/workflows/invoiceEncoder.d.ts +13 -0
  24. package/dist/encoders/workflows/invoiceEncoder.d.ts.map +1 -0
  25. package/dist/encoders/workflows/invoiceEncoder.js +49 -0
  26. package/dist/encoders/workflows/invoiceEncoder.js.map +1 -0
  27. package/dist/encoders/workflows/itEncoder.d.ts +15 -0
  28. package/dist/encoders/workflows/itEncoder.d.ts.map +1 -0
  29. package/dist/encoders/workflows/itEncoder.js +69 -0
  30. package/dist/encoders/workflows/itEncoder.js.map +1 -0
  31. package/dist/encoders/workflows/payrollEncoder.d.ts +17 -0
  32. package/dist/encoders/workflows/payrollEncoder.d.ts.map +1 -0
  33. package/dist/encoders/workflows/payrollEncoder.js +76 -0
  34. package/dist/encoders/workflows/payrollEncoder.js.map +1 -0
  35. package/dist/index.d.ts +22 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +35 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/schema.d.ts +86 -0
  40. package/dist/schema.d.ts.map +1 -0
  41. package/dist/schema.js +25 -0
  42. package/dist/schema.js.map +1 -0
  43. package/dist/validator.d.ts +10 -0
  44. package/dist/validator.d.ts.map +1 -0
  45. package/dist/validator.js +112 -0
  46. package/dist/validator.js.map +1 -0
  47. package/package.json +47 -0
  48. package/tests/smoke.test.ts +162 -0
  49. package/tsconfig.json +29 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * AACP v1.1 Payroll Workflow Encoder
3
+ * Zero-cost deterministic encoding for HR payroll workflows.
4
+ * Mirrors Python PayrollEncoder exactly.
5
+ */
6
+
7
+ import { RuleBasedEncoder } from "../ruleBasedEncoder";
8
+ import { EncodedPacket } from "../../schema";
9
+
10
+ export class PayrollEncoder {
11
+ private enc = new RuleBasedEncoder();
12
+
13
+ fetchEmployees(
14
+ period: string,
15
+ returnAgent = "HR-Agent",
16
+ priority = "1",
17
+ ): EncodedPacket {
18
+ return this.enc.encode({
19
+ task: "FETCH", domain: "HR",
20
+ res: "emp_salary", period,
21
+ filterExpr: "status=active", fmt: "json",
22
+ returnAgent, priority,
23
+ });
24
+ }
25
+
26
+ fetchBudgets(
27
+ period: string,
28
+ returnAgent = "HR-Agent",
29
+ priority = "1",
30
+ ): EncodedPacket {
31
+ return this.enc.encode({
32
+ task: "FETCH", domain: "FIN",
33
+ res: "budget_cc", period,
34
+ fmt: "json",
35
+ returnAgent, priority,
36
+ });
37
+ }
38
+
39
+ mergeAndCalculate(
40
+ period: string,
41
+ rules = "payroll_v2",
42
+ returnAgent = "HR-Agent",
43
+ priority = "1",
44
+ ): EncodedPacket {
45
+ return this.enc.encode({
46
+ task: "MERGE", domain: "HR",
47
+ rules, validate: "budget_cc",
48
+ returnAgent, priority,
49
+ });
50
+ }
51
+
52
+ generateReport(
53
+ period: string,
54
+ _prevPeriod: string,
55
+ returnAgent = "HR-Agent",
56
+ priority = "2",
57
+ ): EncodedPacket {
58
+ return this.enc.encode({
59
+ task: "REPORT", domain: "HR",
60
+ fmt: "pdf,xlsx", highlight: "REVIEW_REQ",
61
+ returnAgent, priority,
62
+ });
63
+ }
64
+
65
+ logRun(
66
+ _period: string,
67
+ actor = "HR-Agent",
68
+ chain?: string[],
69
+ status = "review_required",
70
+ returnAgent = "AUD-Agent",
71
+ priority = "2",
72
+ ): EncodedPacket {
73
+ return this.enc.encode({
74
+ task: "LOG", domain: "HR",
75
+ actor,
76
+ chain: chain ?? ["HRMS", "FIN", "PAY", "RPT"],
77
+ status,
78
+ returnAgent, priority,
79
+ });
80
+ }
81
+
82
+ sendReport(
83
+ period: string,
84
+ to?: string[],
85
+ flagMsg = "review_required",
86
+ returnAgent = "HR-Agent",
87
+ priority = "2",
88
+ ): EncodedPacket {
89
+ const periodLabel = period.replace(/-/g, "_");
90
+ return this.enc.encode({
91
+ task: "SEND", domain: "HR",
92
+ to: to ?? ["fin_director", "hr_director"],
93
+ subj: `payroll_${periodLabel}_REVIEW_REQ`,
94
+ att: `rpt://payroll/${period}:pdf`,
95
+ flagMsg,
96
+ returnAgent, priority,
97
+ });
98
+ }
99
+
100
+ fullRun(period: string, prevPeriod: string): EncodedPacket[] {
101
+ return [
102
+ this.fetchEmployees(period),
103
+ this.fetchBudgets(period),
104
+ this.mergeAndCalculate(period),
105
+ this.generateReport(period, prevPeriod),
106
+ this.logRun(period),
107
+ this.sendReport(period),
108
+ ];
109
+ }
110
+ }
package/Src/index.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * AACP v1.1 TypeScript SDK
3
+ * Agent Action Compression Protocol
4
+ *
5
+ * @example
6
+ * import { PayrollEncoder, AACPValidator, AACPDecoder } from "aacp-ts";
7
+ *
8
+ * const enc = new PayrollEncoder();
9
+ * const pkt = enc.fetchEmployees("2026-03");
10
+ * console.log(pkt.packet);
11
+ * // FETCH|HR|return:HR-Agent|p:1|aacp:1.1|res:emp_salary|period:2026-03|filter:status=active|fmt:json
12
+ */
13
+
14
+ export { AACP_VERSION, VALID_TASKS, VALID_DOMAINS, EXTENDED_FIELDS } from "./schema";
15
+ export type {
16
+ EncodedPacket, DecodedPacket, ValidationResult,
17
+ EncodeParams, CompressionLoss, EncoderType,
18
+ } from "./schema";
19
+
20
+ export { AACPValidator } from "./validator";
21
+ export { AACPDecoder } from "./decoder";
22
+ export { RuleBasedEncoder } from "./encoders/ruleBasedEncoder";
23
+
24
+ export { PayrollEncoder } from "./encoders/workflows/payrollEncoder";
25
+ export { ITEncoder } from "./encoders/workflows/itEncoder";
26
+ export { InvoiceEncoder } from "./encoders/workflows/invoiceEncoder";
27
+ export { ContractEncoder } from "./encoders/workflows/contractEncoder";
package/Src/schema.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * AACP v1.1 Schema
3
+ * Types and constants for the Agent Action Compression Protocol.
4
+ */
5
+
6
+ export const AACP_VERSION = "1.1";
7
+
8
+ export const VALID_TASKS = new Set([
9
+ "FETCH", "PROC", "FLAG", "RESOLVE", "LOG", "SEND",
10
+ "BUILD", "MERGE", "CALC", "REPORT", "ACK", "SYNC",
11
+ ]);
12
+
13
+ export const VALID_DOMAINS = new Set([
14
+ "HR", "FIN", "SALES", "LEGAL", "IT", "CS", "MKT",
15
+ ]);
16
+
17
+ export const VALID_PRIORITIES = new Set(["1", "2", "3"]);
18
+
19
+ export const EXTENDED_FIELDS = new Set([
20
+ "src", "src_prev", "rules", "validate", "tmpl", "data_ptr",
21
+ "amt", "ccy", "sup", "match", "terms", "type", "party",
22
+ "clause", "issue", "risk", "block", "flags", "req",
23
+ "highlight", "status", "to", "subj", "att", "flag_msg",
24
+ "tone", "sentiment", "actor", "chain", "prog",
25
+ "ltv", "loyalty", "urgency",
26
+ ]);
27
+
28
+ export type CompressionLoss = "none" | "minor" | "partial" | "significant";
29
+ export type EncoderType = "rule_based" | "llm" | "fallback";
30
+
31
+ export interface ValidationResult {
32
+ valid: boolean;
33
+ errors: string[];
34
+ warnings: string[];
35
+ summary(): string;
36
+ }
37
+
38
+ export interface EncodedPacket {
39
+ packet: string;
40
+ domain: string;
41
+ task: string;
42
+ tokenEstimateEnglish: number;
43
+ tokenEstimatePacket: number;
44
+ compressionLoss: CompressionLoss;
45
+ lossNote: string | null;
46
+ aacpVersion: string;
47
+ encoderType: EncoderType;
48
+ apiCostUsd: number;
49
+ readonly compressionRatio: number;
50
+ readonly reductionPct: string;
51
+ summary(): string;
52
+ }
53
+
54
+ export interface DecodedPacket {
55
+ english: string;
56
+ parsed: Record<string, string>;
57
+ isComplete: boolean;
58
+ caveat: string;
59
+ }
60
+
61
+ /** Encode parameters for the rule-based encoder */
62
+ export interface EncodeParams {
63
+ task: string;
64
+ domain: string;
65
+ returnAgent: string;
66
+ res?: string;
67
+ period?: string;
68
+ filterExpr?: string;
69
+ fields?: string[];
70
+ fmt?: string;
71
+ priority?: string;
72
+ src?: string[];
73
+ srcPrev?: string;
74
+ rules?: string;
75
+ validate?: string;
76
+ template?: string;
77
+ dataPtr?: string;
78
+ amt?: string | number;
79
+ ccy?: string;
80
+ supplier?: string;
81
+ match?: string;
82
+ terms?: string;
83
+ docType?: string;
84
+ party?: string;
85
+ clause?: string;
86
+ issue?: string;
87
+ risk?: string;
88
+ block?: string;
89
+ flags?: string[];
90
+ flagsInherit?: string[];
91
+ req?: string[];
92
+ highlight?: string;
93
+ status?: string;
94
+ to?: string[];
95
+ subj?: string;
96
+ att?: string;
97
+ flagMsg?: string;
98
+ tone?: string;
99
+ sentiment?: string;
100
+ actor?: string;
101
+ chain?: string[];
102
+ prog?: number;
103
+ ltv?: string | number;
104
+ loyalty?: string;
105
+ urgency?: string;
106
+ [key: string]: unknown;
107
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * AACP v1.1 Validator
3
+ * Validates pipe-delimited AACP packets against the v1.1 schema.
4
+ * Pure logic. No LLM calls. Fast and free.
5
+ */
6
+
7
+ import {
8
+ VALID_TASKS, VALID_DOMAINS, VALID_PRIORITIES,
9
+ EXTENDED_FIELDS, AACP_VERSION,
10
+ ValidationResult,
11
+ } from "./schema";
12
+
13
+ class ValidationResultImpl implements ValidationResult {
14
+ constructor(
15
+ public valid: boolean,
16
+ public errors: string[] = [],
17
+ public warnings: string[] = [],
18
+ ) {}
19
+
20
+ summary(): string {
21
+ const lines = [
22
+ "VALIDATION RESULT",
23
+ ` Status: ${this.valid ? "VALID" : "INVALID"}`,
24
+ ];
25
+ for (const e of this.errors) lines.push(` ERROR: ${e}`);
26
+ for (const w of this.warnings) lines.push(` WARN: ${w}`);
27
+ if (!this.errors.length && !this.warnings.length) {
28
+ lines.push(" No issues.");
29
+ }
30
+ return lines.join("\n");
31
+ }
32
+ }
33
+
34
+ export class AACPValidator {
35
+
36
+ validate(packet: string): ValidationResult {
37
+ const errors: string[] = [];
38
+ const warnings: string[] = [];
39
+
40
+ if (!packet || !packet.trim()) {
41
+ return new ValidationResultImpl(false, ["Empty packet."]);
42
+ }
43
+
44
+ const fields = packet.trim().split("|");
45
+
46
+ if (fields.length < 3) {
47
+ return new ValidationResultImpl(false, [
48
+ `Packet has ${fields.length} fields. Minimum required: TASK|DOM|return:AGENT|aacp:VERSION`,
49
+ ]);
50
+ }
51
+
52
+ const task = fields[0].trim();
53
+ const dom = fields[1].trim();
54
+
55
+ // Named fields from position 2 onwards
56
+ const named: Record<string, string> = {};
57
+ for (const f of fields.slice(2)) {
58
+ const trimmed = f.trim();
59
+ if (!trimmed) continue;
60
+ const colonIdx = trimmed.indexOf(":");
61
+ if (colonIdx === -1) {
62
+ warnings.push(`Field "${trimmed}" has no colon separator — expected key:value.`);
63
+ continue;
64
+ }
65
+ const key = trimmed.slice(0, colonIdx).toLowerCase();
66
+ const val = trimmed.slice(colonIdx + 1);
67
+ named[key] = val;
68
+ }
69
+
70
+ // Required: TASK
71
+ if (!task) {
72
+ errors.push(`Field 0 (TASK) is empty. Valid: ${[...VALID_TASKS].sort().join(", ")}`);
73
+ } else if (!VALID_TASKS.has(task)) {
74
+ errors.push(`Unknown TASK "${task}". Valid: ${[...VALID_TASKS].sort().join(", ")}`);
75
+ }
76
+
77
+ // Required: DOM
78
+ if (!dom) {
79
+ errors.push(`Field 1 (DOM) is empty. Valid: ${[...VALID_DOMAINS].sort().join(", ")}`);
80
+ } else if (!VALID_DOMAINS.has(dom)) {
81
+ errors.push(`Unknown DOM "${dom}". Valid: ${[...VALID_DOMAINS].sort().join(", ")}`);
82
+ }
83
+
84
+ // Required: return:
85
+ if (!named["return"]) {
86
+ errors.push("Missing required field: return: (receiving agent identifier)");
87
+ }
88
+
89
+ // Required: aacp:
90
+ if (!named["aacp"]) {
91
+ warnings.push(`Missing aacp: version field. Expected aacp:${AACP_VERSION}`);
92
+ } else if (named["aacp"] !== AACP_VERSION) {
93
+ warnings.push(`AACP version "${named["aacp"]}" — current is ${AACP_VERSION}`);
94
+ }
95
+
96
+ // Optional: priority
97
+ if (named["p"] && !VALID_PRIORITIES.has(named["p"])) {
98
+ warnings.push(`Priority "${named["p"]}" non-standard. Expected 1, 2, or 3.`);
99
+ }
100
+
101
+ // Extended field validation
102
+ for (const key of Object.keys(named)) {
103
+ if (["return", "aacp", "p", "res", "period", "filter", "fields", "fmt"].includes(key)) {
104
+ continue;
105
+ }
106
+ if (!EXTENDED_FIELDS.has(key)) {
107
+ warnings.push(
108
+ `Unknown extended field "${key}". ` +
109
+ `May be a valid extension — ensure receiving agent supports it.`
110
+ );
111
+ }
112
+ }
113
+
114
+ // Companion rules
115
+ if (named["sentiment"] && !named["tone"]) {
116
+ warnings.push(
117
+ "sentiment field present without tone. " +
118
+ "Add tone:empathetic|formal|terse for human-facing tasks."
119
+ );
120
+ }
121
+ if (named["ltv"] && !named["ccy"]) {
122
+ warnings.push("ltv field present without ccy — add currency context.");
123
+ }
124
+
125
+ return new ValidationResultImpl(errors.length === 0, errors, warnings);
126
+ }
127
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * AACP v1.1 Decoder
3
+ * Expands AACP packets into human-readable English.
4
+ * Pure logic. No LLM calls.
5
+ * Note: decoded output is structural, not semantic.
6
+ * The packet is always the canonical record.
7
+ */
8
+ import { DecodedPacket } from "./schema";
9
+ export declare class AACPDecoder {
10
+ decode(packet: string): DecodedPacket;
11
+ }
12
+ //# sourceMappingURL=decoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../Src/decoder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA2BzC,qBAAa,WAAW;IAEtB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;CA6FtC"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * AACP v1.1 Decoder
4
+ * Expands AACP packets into human-readable English.
5
+ * Pure logic. No LLM calls.
6
+ * Note: decoded output is structural, not semantic.
7
+ * The packet is always the canonical record.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AACPDecoder = void 0;
11
+ const TASK_VERBS = {
12
+ FETCH: "Retrieve",
13
+ PROC: "Process",
14
+ FLAG: "Flag for review",
15
+ RESOLVE: "Resolve",
16
+ LOG: "Log to audit trail",
17
+ SEND: "Send",
18
+ BUILD: "Build or provision",
19
+ MERGE: "Merge and process",
20
+ CALC: "Calculate",
21
+ REPORT: "Generate report",
22
+ ACK: "Acknowledge",
23
+ SYNC: "Synchronise",
24
+ };
25
+ const DOMAIN_NAMES = {
26
+ HR: "Human Resources",
27
+ FIN: "Finance",
28
+ SALES: "Sales",
29
+ LEGAL: "Legal",
30
+ IT: "IT",
31
+ CS: "Customer Services",
32
+ MKT: "Marketing",
33
+ };
34
+ class AACPDecoder {
35
+ decode(packet) {
36
+ if (!packet || !packet.trim()) {
37
+ return {
38
+ english: "Empty packet.",
39
+ parsed: {},
40
+ isComplete: false,
41
+ caveat: "Decoded output is structural. Packet is the canonical record.",
42
+ };
43
+ }
44
+ const fields = packet.trim().split("|");
45
+ const task = fields[0]?.trim() ?? "";
46
+ const dom = fields[1]?.trim() ?? "";
47
+ const named = {};
48
+ for (const f of fields.slice(2)) {
49
+ const trimmed = f.trim();
50
+ if (!trimmed)
51
+ continue;
52
+ const colonIdx = trimmed.indexOf(":");
53
+ if (colonIdx !== -1) {
54
+ const key = trimmed.slice(0, colonIdx).toLowerCase();
55
+ const val = trimmed.slice(colonIdx + 1);
56
+ named[key] = val;
57
+ }
58
+ }
59
+ const verb = TASK_VERBS[task] ?? task.toLowerCase();
60
+ const domainName = DOMAIN_NAMES[dom] ?? dom;
61
+ const returnTo = named["return"] ?? "unknown agent";
62
+ const priority = named["p"] ?? "2";
63
+ const priorityLabel = priority === "1" ? "critical priority"
64
+ : priority === "3" ? "low priority"
65
+ : "standard priority";
66
+ const parts = [];
67
+ // Core action
68
+ const res = named["res"];
69
+ if (res) {
70
+ parts.push(`${verb} ${res.replace(/_/g, " ")} from the ${domainName} domain`);
71
+ }
72
+ else {
73
+ parts.push(`${verb} in the ${domainName} domain`);
74
+ }
75
+ // Time period
76
+ if (named["period"])
77
+ parts.push(`for period ${named["period"]}`);
78
+ // Filter
79
+ if (named["filter"])
80
+ parts.push(`filtered to ${named["filter"].replace(/=/g, ": ").replace(/_/g, " ")}`);
81
+ // Format
82
+ if (named["fmt"])
83
+ parts.push(`return as ${named["fmt"].toUpperCase()}`);
84
+ // Rules
85
+ if (named["rules"])
86
+ parts.push(`using rules ${named["rules"]}`);
87
+ // Validate
88
+ if (named["validate"])
89
+ parts.push(`validate against ${named["validate"].replace(/_/g, " ")}`);
90
+ // Flags
91
+ if (named["flags"])
92
+ parts.push(`flag: ${named["flags"].replace(/,/g, ", ")}`);
93
+ // Highlight
94
+ if (named["highlight"])
95
+ parts.push(`highlight: ${named["highlight"].replace(/_/g, " ")}`);
96
+ // Risk
97
+ if (named["risk"])
98
+ parts.push(`risk level: ${named["risk"]}`);
99
+ // Amount
100
+ if (named["amt"]) {
101
+ const ccy = named["ccy"] ?? "";
102
+ parts.push(`amount: ${ccy} ${named["amt"]}`.trim());
103
+ }
104
+ // Recipient
105
+ if (named["to"])
106
+ parts.push(`send to: ${named["to"].replace(/,/g, ", ")}`);
107
+ // Actor / chain
108
+ if (named["actor"])
109
+ parts.push(`initiated by ${named["actor"]}`);
110
+ if (named["chain"])
111
+ parts.push(`agent chain: ${named["chain"].replace(/,/g, " → ")}`);
112
+ // Routing
113
+ parts.push(`return result to ${returnTo} (${priorityLabel})`);
114
+ const english = parts.join(", ") + ".";
115
+ return {
116
+ english,
117
+ parsed: { task, domain: dom, ...named },
118
+ isComplete: true,
119
+ caveat: "Decoded output is structural. Packet is the canonical record.",
120
+ };
121
+ }
122
+ }
123
+ exports.AACPDecoder = AACPDecoder;
124
+ //# sourceMappingURL=decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoder.js","sourceRoot":"","sources":["../Src/decoder.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,MAAM,UAAU,GAA2B;IACzC,KAAK,EAAI,UAAU;IACnB,IAAI,EAAK,SAAS;IAClB,IAAI,EAAK,iBAAiB;IAC1B,OAAO,EAAE,SAAS;IAClB,GAAG,EAAM,oBAAoB;IAC7B,IAAI,EAAK,MAAM;IACf,KAAK,EAAI,oBAAoB;IAC7B,KAAK,EAAI,mBAAmB;IAC5B,IAAI,EAAK,WAAW;IACpB,MAAM,EAAG,iBAAiB;IAC1B,GAAG,EAAM,aAAa;IACtB,IAAI,EAAK,aAAa;CACvB,CAAC;AAEF,MAAM,YAAY,GAA2B;IAC3C,EAAE,EAAM,iBAAiB;IACzB,GAAG,EAAK,SAAS;IACjB,KAAK,EAAG,OAAO;IACf,KAAK,EAAG,OAAO;IACf,EAAE,EAAM,IAAI;IACZ,EAAE,EAAM,mBA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AK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACjE,IAAI,KAAK,CAAC,OAAO,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAEtF,UAAU;QACV,KAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,KAAK,aAAa,GAAG,CAAC,CAAC;QAE9D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAEvC,OAAO;YACL,OAAO;YACP,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE;YACvC,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,+DAA+D;SACxE,CAAC;IACJ,CAAC;CACF;AA/FD,kCA+FC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * AACP v1.1 Rule-Based Encoder
3
+ * Deterministic, zero-cost encoding for structured input.
4
+ * Everything except TASK and DOM is a named key:value pair.
5
+ * No empty positional slots. No LLM calls.
6
+ */
7
+ import { EncodeParams, EncodedPacket } from "../schema";
8
+ export declare class RuleBasedEncoder {
9
+ private validator;
10
+ encode(params: EncodeParams): EncodedPacket;
11
+ }
12
+ //# sourceMappingURL=ruleBasedEncoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleBasedEncoder.d.ts","sourceRoot":"","sources":["../../Src/encoders/ruleBasedEncoder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAgB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqCtE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAuB;IAExC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa;CA4F5C"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * AACP v1.1 Rule-Based Encoder
4
+ * Deterministic, zero-cost encoding for structured input.
5
+ * Everything except TASK and DOM is a named key:value pair.
6
+ * No empty positional slots. No LLM calls.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RuleBasedEncoder = void 0;
10
+ const schema_1 = require("../schema");
11
+ const validator_1 = require("../validator");
12
+ class EncodedPacketImpl {
13
+ constructor(packet, domain, task, tokenEstimateEnglish, tokenEstimatePacket, compressionLoss, lossNote, aacpVersion, encoderType, apiCostUsd) {
14
+ this.packet = packet;
15
+ this.domain = domain;
16
+ this.task = task;
17
+ this.tokenEstimateEnglish = tokenEstimateEnglish;
18
+ this.tokenEstimatePacket = tokenEstimatePacket;
19
+ this.compressionLoss = compressionLoss;
20
+ this.lossNote = lossNote;
21
+ this.aacpVersion = aacpVersion;
22
+ this.encoderType = encoderType;
23
+ this.apiCostUsd = apiCostUsd;
24
+ }
25
+ get compressionRatio() {
26
+ if (this.tokenEstimateEnglish === 0)
27
+ return 0;
28
+ return 1 - this.tokenEstimatePacket / this.tokenEstimateEnglish;
29
+ }
30
+ get reductionPct() {
31
+ return `${(this.compressionRatio * 100).toFixed(1)}%`;
32
+ }
33
+ summary() {
34
+ return [
35
+ `PACKET [${this.domain}/${this.task}]`,
36
+ ` Encoder: ${this.encoderType} Cost: $${this.apiCostUsd.toFixed(4)}`,
37
+ ` Loss: ${this.compressionLoss}`,
38
+ "",
39
+ this.packet,
40
+ ].join("\n");
41
+ }
42
+ }
43
+ class RuleBasedEncoder {
44
+ constructor() {
45
+ this.validator = new validator_1.AACPValidator();
46
+ }
47
+ encode(params) {
48
+ const { task, domain, returnAgent, priority = "2", res, period, filterExpr, fields, fmt, src, srcPrev, rules, validate, template, dataPtr, amt, ccy, supplier, match, terms, docType, party, clause, issue, risk, block, flags, flagsInherit, req, highlight, status, to, subj, att, flagMsg, tone, sentiment, actor, chain, prog, ltv, loyalty, urgency, } = params;
49
+ // Core: TASK and DOM positional, everything else named
50
+ const parts = [
51
+ task.toUpperCase(),
52
+ domain.toUpperCase(),
53
+ `return:${returnAgent}`,
54
+ `p:${priority}`,
55
+ `aacp:${schema_1.AACP_VERSION}`,
56
+ ];
57
+ const add = (key, val) => {
58
+ if (val !== null && val !== undefined && String(val).trim() !== "") {
59
+ parts.push(`${key}:${val}`);
60
+ }
61
+ };
62
+ add("res", res);
63
+ add("period", period);
64
+ add("filter", filterExpr);
65
+ add("fields", fields?.join(","));
66
+ add("fmt", fmt);
67
+ add("src", src?.join(","));
68
+ add("src_prev", srcPrev);
69
+ add("rules", rules);
70
+ add("validate", validate);
71
+ add("tmpl", template);
72
+ add("data_ptr", dataPtr);
73
+ add("amt", amt !== undefined ? String(amt) : undefined);
74
+ add("ccy", ccy?.toUpperCase());
75
+ add("sup", supplier?.replace(/ /g, "-"));
76
+ add("match", match);
77
+ add("terms", terms);
78
+ add("type", docType?.toUpperCase());
79
+ add("party", party?.replace(/ /g, "-"));
80
+ add("clause", clause);
81
+ add("issue", issue?.replace(/ /g, "_").toLowerCase());
82
+ add("risk", risk?.toLowerCase());
83
+ add("block", block);
84
+ add("flags", flags?.join(","));
85
+ add("flags_inherit", flagsInherit?.join(","));
86
+ add("req", req?.join(","));
87
+ add("highlight", highlight);
88
+ add("status", status);
89
+ add("to", to?.join(","));
90
+ add("subj", subj?.replace(/ /g, "_"));
91
+ add("att", att);
92
+ add("flag_msg", flagMsg?.replace(/ /g, "_"));
93
+ add("sentiment", sentiment?.toLowerCase());
94
+ add("tone", tone?.toLowerCase());
95
+ add("prog", prog !== undefined ? prog.toFixed(2) : undefined);
96
+ add("actor", actor);
97
+ add("chain", chain?.join(","));
98
+ add("ltv", ltv !== undefined ? String(ltv) : undefined);
99
+ add("loyalty", loyalty);
100
+ add("urgency", urgency?.toLowerCase());
101
+ const packet = parts.join("|");
102
+ const validation = this.validator.validate(packet);
103
+ if (!validation.valid) {
104
+ throw new Error(`Rule-based encoder produced invalid packet:\n` +
105
+ validation.errors.join("\n") + "\n" + packet);
106
+ }
107
+ const tokenEstimatePacket = Math.max(1, Math.floor(packet.length / 4));
108
+ const tokenEstimateEnglish = 15 + parts.length * 8;
109
+ return new EncodedPacketImpl(packet, domain.toUpperCase(), task.toUpperCase(), tokenEstimateEnglish, tokenEstimatePacket, "none", null, schema_1.AACP_VERSION, "rule_based", 0.0);
110
+ }
111
+ }
112
+ exports.RuleBasedEncoder = RuleBasedEncoder;
113
+ //# sourceMappingURL=ruleBasedEncoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleBasedEncoder.js","sourceRoot":"","sources":["../../Src/encoders/ruleBasedEncoder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sCAAsE;AACtE,4CAA6C;AAE7C,MAAM,iBAAiB;IACrB,YACS,MAAc,EACd,MAAc,EACd,IAAY,EACZ,oBAA4B,EAC5B,mBAA2B,EAC3B,eAA6D,EAC7D,QAAuB,EACvB,WAAmB,EACnB,WAA8C,EAC9C,UAAkB;QATlB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,oBAAe,GAAf,eAAe,CAA8C;QAC7D,aAAQ,GAAR,QAAQ,CAAe;QACvB,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAmC;QAC9C,eAAU,GAAV,UAAU,CAAQ;IACxB,CAAC;IAEJ,IAAI,gBAAgB;QAClB,IAAI,IAAI,CAAC,oBAAoB,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,CAAC;IAClE,CAAC;IAED,IAAI,YAAY;QACd,OAAO,GAAG,CAAC,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,C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AC;CACF;AA/FD,4CA+FC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * AACP v1.1 Contract Review Workflow Encoder
3
+ * Zero-cost deterministic encoding for legal contract review workflows.
4
+ */
5
+ import { EncodedPacket } from "../../schema";
6
+ export declare class ContractEncoder {
7
+ private enc;
8
+ flagClause(docType: string, party: string, clause: string, issue: string, risk: "low" | "medium" | "high" | "critical", blockAction?: string, returnAgent?: string, priority?: string): EncodedPacket;
9
+ reviewContract(docType: string, party: string, rules: string, returnAgent?: string, priority?: string): EncodedPacket;
10
+ logReview(docType: string, party: string, status: string, returnAgent?: string, priority?: string): EncodedPacket;
11
+ fullReview(docType: string, party: string, rules: string): EncodedPacket[];
12
+ }
13
+ //# sourceMappingURL=contractEncoder.d.ts.map