@ddse/acm-examples 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/examples/entitlement/tasks.d.ts +44 -0
- package/dist/src/examples/entitlement/tasks.d.ts.map +1 -0
- package/dist/src/examples/entitlement/tasks.js +27 -0
- package/dist/src/examples/entitlement/tasks.js.map +1 -0
- package/dist/src/examples/entitlement/tools.d.ts +74 -0
- package/dist/src/examples/entitlement/tools.d.ts.map +1 -0
- package/dist/src/examples/entitlement/tools.js +63 -0
- package/dist/src/examples/entitlement/tools.js.map +1 -0
- package/dist/src/framework.d.ts +19 -0
- package/dist/src/framework.d.ts.map +1 -0
- package/dist/src/framework.js +42 -0
- package/dist/src/framework.js.map +1 -0
- package/dist/tests/entitlement.test.d.ts +2 -0
- package/dist/tests/entitlement.test.d.ts.map +1 -0
- package/dist/tests/entitlement.test.js +30 -0
- package/dist/tests/entitlement.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -9
- package/bin/acm-demo.ts +0 -495
- package/data/coaching/agents.json +0 -16
- package/data/coaching/transcripts.json +0 -37
- package/data/documents.json +0 -72
- package/data/entitlement/customers.json +0 -38
- package/data/entitlement/policies.json +0 -38
- package/data/incidents/incidents.json +0 -30
- package/data/incidents/routing_rules.json +0 -36
- package/data/invoices/invoices.json +0 -38
- package/data/invoices/purchase-orders.json +0 -38
- package/data/issues.json +0 -99
- package/data/knowledge/docs/kb-001.md +0 -7
- package/data/knowledge/docs/kb-002.md +0 -7
- package/data/knowledge/docs/kb-003.md +0 -9
- package/data/knowledge/index.json +0 -25
- package/data/orders.json +0 -106
- package/docs/examples-architecture.md +0 -144
- package/docs/successrun.md +0 -1022
- package/src/context/directives.ts +0 -366
- package/src/context/index.ts +0 -1
- package/src/data/coaching.ts +0 -50
- package/src/data/entitlement.ts +0 -60
- package/src/data/incidents.ts +0 -78
- package/src/data/invoices.ts +0 -103
- package/src/data/knowledge.ts +0 -77
- package/src/data/loader.ts +0 -80
- package/src/examples/scenarios.ts +0 -724
- package/src/goals/index.ts +0 -18
- package/src/policy.ts +0 -30
- package/src/registries.ts +0 -48
- package/src/renderer.ts +0 -82
- package/src/search/bm25.ts +0 -173
- package/src/search/index.ts +0 -2
- package/src/tasks/coaching.ts +0 -217
- package/src/tasks/entitlement.ts +0 -197
- package/src/tasks/incidents.ts +0 -277
- package/src/tasks/index.ts +0 -6
- package/src/tasks/invoices.ts +0 -269
- package/src/tasks/knowledge.ts +0 -169
- package/src/tasks/legacy.ts +0 -112
- package/src/tools/coaching/index.ts +0 -197
- package/src/tools/entitlement/index.ts +0 -199
- package/src/tools/incidents/index.ts +0 -185
- package/src/tools/index.ts +0 -192
- package/src/tools/invoices/index.ts +0 -165
- package/src/tools/knowledge/index.ts +0 -203
- package/tests/bm25.test.ts +0 -129
- package/tests/integration.test.ts +0 -163
- package/tests/plan-hydration.test.ts +0 -33
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Task, type RunContext } from '@acm/sdk';
|
|
2
|
+
export declare class FetchCustomerProfileTask extends Task<{
|
|
3
|
+
customerId: string;
|
|
4
|
+
}, any> {
|
|
5
|
+
private readonly tool;
|
|
6
|
+
constructor();
|
|
7
|
+
execute(_ctx: RunContext, input: {
|
|
8
|
+
customerId: string;
|
|
9
|
+
}): Promise<any>;
|
|
10
|
+
verification(): string[];
|
|
11
|
+
}
|
|
12
|
+
export declare class EvaluateEntitlementTask extends Task<{
|
|
13
|
+
customer: any;
|
|
14
|
+
}, {
|
|
15
|
+
allow: boolean;
|
|
16
|
+
rationale: string[];
|
|
17
|
+
}> {
|
|
18
|
+
private readonly tool;
|
|
19
|
+
constructor();
|
|
20
|
+
execute(_ctx: RunContext, input: {
|
|
21
|
+
customer: any;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
allow: boolean;
|
|
24
|
+
rationale: string[];
|
|
25
|
+
}>;
|
|
26
|
+
verification(): string[];
|
|
27
|
+
}
|
|
28
|
+
export declare class NotifySupervisorTask extends Task<{
|
|
29
|
+
customerId: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}, {
|
|
32
|
+
notified: boolean;
|
|
33
|
+
}> {
|
|
34
|
+
private readonly tool;
|
|
35
|
+
constructor();
|
|
36
|
+
execute(_ctx: RunContext, input: {
|
|
37
|
+
customerId: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
notified: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
verification(): string[];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../../src/examples/entitlement/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,wBAAyB,SAAQ,IAAI,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,CAAC;IAC7E,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkC;;IAEjD,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAG7D,YAAY;CACb;AAED,qBAAa,uBAAwB,SAAQ,IAAI,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;IAC3G,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiC;;IAEhD,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE;;;;IAGxD,YAAY;CACb;AAED,qBAAa,oBAAqB,SAAQ,IAAI,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;IAC3G,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;;IAE7C,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;;;IAG7E,YAAY;CACb"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Task } from '@acm/sdk';
|
|
2
|
+
import { FetchCustomerProfileTool, EvaluateEntitlementTool, NotifySupervisorTool } from './tools.js';
|
|
3
|
+
export class FetchCustomerProfileTask extends Task {
|
|
4
|
+
tool = new FetchCustomerProfileTool();
|
|
5
|
+
constructor() { super('fetch_profile', 'fetch_customer_profile'); }
|
|
6
|
+
async execute(_ctx, input) {
|
|
7
|
+
return this.tool.call({ customerId: input.customerId });
|
|
8
|
+
}
|
|
9
|
+
verification() { return ['output != null']; }
|
|
10
|
+
}
|
|
11
|
+
export class EvaluateEntitlementTask extends Task {
|
|
12
|
+
tool = new EvaluateEntitlementTool();
|
|
13
|
+
constructor() { super('evaluate_entitlement', 'evaluate_entitlement'); }
|
|
14
|
+
async execute(_ctx, input) {
|
|
15
|
+
return this.tool.call({ customer: input.customer });
|
|
16
|
+
}
|
|
17
|
+
verification() { return ['typeof output.allow === "boolean"']; }
|
|
18
|
+
}
|
|
19
|
+
export class NotifySupervisorTask extends Task {
|
|
20
|
+
tool = new NotifySupervisorTool();
|
|
21
|
+
constructor() { super('notify_supervisor', 'notify_supervisor'); }
|
|
22
|
+
async execute(_ctx, input) {
|
|
23
|
+
return this.tool.call({ customerId: input.customerId, reason: input.reason });
|
|
24
|
+
}
|
|
25
|
+
verification() { return ['output.notified === true']; }
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","source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UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,YAAY,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Tool } from '@acm/sdk';
|
|
2
|
+
export declare class FetchCustomerProfileTool extends Tool<{
|
|
3
|
+
customerId: string;
|
|
4
|
+
}, any> {
|
|
5
|
+
name(): string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly customerId: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly required: readonly ["customerId"];
|
|
15
|
+
readonly additionalProperties: false;
|
|
16
|
+
};
|
|
17
|
+
call(input: {
|
|
18
|
+
customerId: string;
|
|
19
|
+
}): Promise<any>;
|
|
20
|
+
}
|
|
21
|
+
export declare class EvaluateEntitlementTool extends Tool<{
|
|
22
|
+
customer: any;
|
|
23
|
+
}, {
|
|
24
|
+
allow: boolean;
|
|
25
|
+
rationale: string[];
|
|
26
|
+
}> {
|
|
27
|
+
name(): string;
|
|
28
|
+
description: string;
|
|
29
|
+
inputSchema: {
|
|
30
|
+
readonly type: "object";
|
|
31
|
+
readonly properties: {
|
|
32
|
+
readonly customer: {
|
|
33
|
+
readonly type: "object";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly required: readonly ["customer"];
|
|
37
|
+
readonly additionalProperties: true;
|
|
38
|
+
};
|
|
39
|
+
call(input: {
|
|
40
|
+
customer: any;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
allow: boolean;
|
|
43
|
+
rationale: string[];
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export declare class NotifySupervisorTool extends Tool<{
|
|
47
|
+
customerId: string;
|
|
48
|
+
reason: string;
|
|
49
|
+
}, {
|
|
50
|
+
notified: boolean;
|
|
51
|
+
}> {
|
|
52
|
+
name(): string;
|
|
53
|
+
description: string;
|
|
54
|
+
inputSchema: {
|
|
55
|
+
readonly type: "object";
|
|
56
|
+
readonly properties: {
|
|
57
|
+
readonly customerId: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
};
|
|
60
|
+
readonly reason: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly required: readonly ["customerId", "reason"];
|
|
65
|
+
readonly additionalProperties: false;
|
|
66
|
+
};
|
|
67
|
+
call(_input: {
|
|
68
|
+
customerId: string;
|
|
69
|
+
reason: string;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
notified: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/examples/entitlement/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,qBAAa,wBAAyB,SAAQ,IAAI,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,CAAC;IAC7E,IAAI;IACJ,WAAW,SAAiD;IAC5D,WAAW;;;;;;;;;MAKA;IAEL,IAAI,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;CAKzC;AAED,qBAAa,uBAAwB,SAAQ,IAAI,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;IAC3G,IAAI;IACJ,WAAW,SAAmE;IAC9E,WAAW;;;;;;;;;MAKA;IAEL,IAAI,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE;;;;CAqBpC;AAED,qBAAa,oBAAqB,SAAQ,IAAI,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;IAC3G,IAAI;IACJ,WAAW,SAAyC;IACpD,WAAW;;;;;;;;;;;;MAQA;IAEL,IAAI,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CAG3F"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Tool } from '@acm/sdk';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
export class FetchCustomerProfileTool extends Tool {
|
|
4
|
+
name() { return 'fetch_customer_profile'; }
|
|
5
|
+
description = 'Fetch customer profile from synthetic store';
|
|
6
|
+
inputSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: { customerId: { type: 'string' } },
|
|
9
|
+
required: ['customerId'],
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
};
|
|
12
|
+
async call(input) {
|
|
13
|
+
const raw = await fs.readFile(new URL('../../../data/entitlement/customers.json', import.meta.url));
|
|
14
|
+
const data = JSON.parse(raw.toString());
|
|
15
|
+
return data.find((c) => c.id === input.customerId) ?? null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class EvaluateEntitlementTool extends Tool {
|
|
19
|
+
name() { return 'evaluate_entitlement'; }
|
|
20
|
+
description = 'Evaluate whether a customer is entitled based on policy rules';
|
|
21
|
+
inputSchema = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: { customer: { type: 'object' } },
|
|
24
|
+
required: ['customer'],
|
|
25
|
+
additionalProperties: true,
|
|
26
|
+
};
|
|
27
|
+
async call(input) {
|
|
28
|
+
const raw = await fs.readFile(new URL('../../../data/entitlement/policies.json', import.meta.url));
|
|
29
|
+
const p = JSON.parse(raw.toString());
|
|
30
|
+
const rationale = [];
|
|
31
|
+
if (input.customer.ageMonths < p.minAccountAgeMonths) {
|
|
32
|
+
rationale.push('Account too new');
|
|
33
|
+
}
|
|
34
|
+
if (!p.tiersAllowed.includes(input.customer.tier)) {
|
|
35
|
+
rationale.push('Tier not eligible');
|
|
36
|
+
}
|
|
37
|
+
const deniedByFlag = (input.customer.complianceFlags || []).find((f) => p.denyIfComplianceFlags.includes(f));
|
|
38
|
+
if (deniedByFlag) {
|
|
39
|
+
rationale.push(`Compliance flag: ${deniedByFlag}`);
|
|
40
|
+
}
|
|
41
|
+
const allow = rationale.length === 0;
|
|
42
|
+
if (allow)
|
|
43
|
+
rationale.push('Meets policy criteria');
|
|
44
|
+
return { allow, rationale };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class NotifySupervisorTool extends Tool {
|
|
48
|
+
name() { return 'notify_supervisor'; }
|
|
49
|
+
description = 'Notify supervisor for denial branch';
|
|
50
|
+
inputSchema = {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
customerId: { type: 'string' },
|
|
54
|
+
reason: { type: 'string' },
|
|
55
|
+
},
|
|
56
|
+
required: ['customerId', 'reason'],
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
};
|
|
59
|
+
async call(_input) {
|
|
60
|
+
return { notified: true };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../src/examples/entitlement/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,MAAM,OAAO,wBAAyB,SAAQ,IAAiC;IAC7E,IAAI,KAAK,OAAO,wBAAwB,CAAC,CAAC,CAAC;IAC3C,WAAW,GAA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E,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DefaultStreamSink, ExternalContextProviderAdapter, type CapabilityRegistry } from '@acm/sdk';
|
|
2
|
+
import { ExecutionEngine } from '@acm/framework';
|
|
3
|
+
export type Provider = 'ollama' | 'vllm';
|
|
4
|
+
export interface DemoFrameworkOptions {
|
|
5
|
+
provider?: Provider;
|
|
6
|
+
model?: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
capabilityRegistry: CapabilityRegistry;
|
|
9
|
+
toolRegistry: any;
|
|
10
|
+
policyEngine?: any;
|
|
11
|
+
contextProvider?: ExternalContextProviderAdapter;
|
|
12
|
+
stream?: DefaultStreamSink;
|
|
13
|
+
allowedTools?: string[];
|
|
14
|
+
engine?: ExecutionEngine;
|
|
15
|
+
}
|
|
16
|
+
export declare function createDemoFramework(opts: DemoFrameworkOptions): {
|
|
17
|
+
framework: any;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=framework.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.d.ts","sourceRoot":"","sources":["../../src/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,8BAA8B,EAC9B,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEzC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,eAAe,CAAC,EAAE,8BAA8B,CAAC;IACjD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB;;EAiD7D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DeterministicNucleus, } from '@acm/sdk';
|
|
2
|
+
import { createOllamaClient, createVLLMClient } from '@acm/llm';
|
|
3
|
+
import { ACMFramework, ExecutionEngine } from '@acm/framework';
|
|
4
|
+
export function createDemoFramework(opts) {
|
|
5
|
+
const provider = opts.provider ?? 'ollama';
|
|
6
|
+
const model = opts.model ?? 'llama3.1';
|
|
7
|
+
const llm = provider === 'ollama' ? createOllamaClient(model, opts.baseUrl) : createVLLMClient(model, opts.baseUrl);
|
|
8
|
+
if (!llm.generateWithTools) {
|
|
9
|
+
throw new Error('Selected LLM provider does not support structured tool calls required by Nucleus.');
|
|
10
|
+
}
|
|
11
|
+
let activeLedger;
|
|
12
|
+
const nucleusCall = async (prompt, tools, callConfig) => {
|
|
13
|
+
const toolDefs = tools.map(tool => ({
|
|
14
|
+
name: tool.name,
|
|
15
|
+
description: tool.description ?? 'Nucleus tool',
|
|
16
|
+
inputSchema: tool.inputSchema ?? { type: 'object', properties: {} },
|
|
17
|
+
}));
|
|
18
|
+
const response = await llm.generateWithTools([{ role: 'system', content: prompt }], toolDefs, { temperature: callConfig.temperature, seed: callConfig.seed, maxTokens: callConfig.maxTokens });
|
|
19
|
+
return {
|
|
20
|
+
reasoning: response.text,
|
|
21
|
+
toolCalls: (response.toolCalls ?? []).map(tc => ({ id: tc.id, name: tc.name, input: tc.arguments })),
|
|
22
|
+
raw: response.raw,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const framework = ACMFramework.create({
|
|
26
|
+
capabilityRegistry: opts.capabilityRegistry,
|
|
27
|
+
toolRegistry: opts.toolRegistry,
|
|
28
|
+
policyEngine: opts.policyEngine,
|
|
29
|
+
contextProvider: opts.contextProvider,
|
|
30
|
+
defaultStream: opts.stream,
|
|
31
|
+
nucleus: {
|
|
32
|
+
call: nucleusCall,
|
|
33
|
+
llmConfig: { provider: llm.name(), model, temperature: 0.1, maxTokens: 512 },
|
|
34
|
+
hooks: { preflight: true, postcheck: true },
|
|
35
|
+
allowedTools: opts.allowedTools,
|
|
36
|
+
factory: (ledger) => (config) => new DeterministicNucleus(config, nucleusCall, (entry) => ledger.append(entry.type, entry.details)),
|
|
37
|
+
},
|
|
38
|
+
execution: { engine: opts.engine ?? ExecutionEngine.ACM },
|
|
39
|
+
});
|
|
40
|
+
return { framework };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.js","sourceRoot":"","sources":["../../src/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,GAMrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAiB/D,MAAM,UAAU,mBAAmB,CAAC,IAA0B;IAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC;IACvC,MAAM,GAAG,GAAG,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAEpH,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACvG,CAAC;IAED,IAAI,YAAsC,C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C1B,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE;YAC5E,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;YAC3C,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE,CAAC,MAAoB,EAAE,EAAE,CAAC,CAAC,MAAqB,EAAE,EAAE,CAC3D,IAAI,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,KAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SAClH;QACD,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC,GAAG,EAAE;KAC1D,CAAC,CAAC;IAEH,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement.test.d.ts","sourceRoot":"","sources":["../../tests/entitlement.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MemoryLedger } from '@acm/runtime';
|
|
2
|
+
import { DefaultStreamSink } from '@acm/sdk';
|
|
3
|
+
import { SimpleCapabilityRegistry, SimpleToolRegistry } from '../src/registries.js';
|
|
4
|
+
import { createDemoFramework } from '../src/framework.js';
|
|
5
|
+
import { goals, contexts } from '../src/goals/index.js';
|
|
6
|
+
import { FetchCustomerProfileTask, EvaluateEntitlementTask, NotifySupervisorTask } from '../src/examples/entitlement/tasks.js';
|
|
7
|
+
import { FetchCustomerProfileTool, EvaluateEntitlementTool, NotifySupervisorTool } from '../src/examples/entitlement/tools.js';
|
|
8
|
+
async function run() {
|
|
9
|
+
const capabilityRegistry = new SimpleCapabilityRegistry();
|
|
10
|
+
capabilityRegistry.register({ name: 'fetch_customer_profile', sideEffects: false }, new FetchCustomerProfileTask());
|
|
11
|
+
capabilityRegistry.register({ name: 'evaluate_entitlement', sideEffects: false }, new EvaluateEntitlementTask());
|
|
12
|
+
capabilityRegistry.register({ name: 'notify_supervisor', sideEffects: false }, new NotifySupervisorTask());
|
|
13
|
+
const toolRegistry = new SimpleToolRegistry();
|
|
14
|
+
toolRegistry.register(new FetchCustomerProfileTool());
|
|
15
|
+
toolRegistry.register(new EvaluateEntitlementTool());
|
|
16
|
+
toolRegistry.register(new NotifySupervisorTool());
|
|
17
|
+
const { framework } = createDemoFramework({ capabilityRegistry, toolRegistry, stream: new DefaultStreamSink() });
|
|
18
|
+
const planned = await framework.plan({ goal: goals.entitlement, context: contexts.entitlement });
|
|
19
|
+
const exec = await framework.execute({ goal: planned.goal, context: planned.context, existingPlan: { plan: planned.selectedPlan, plannerResult: planned.result }, ledger: new MemoryLedger() });
|
|
20
|
+
const outputs = exec.execution.outputsByTask;
|
|
21
|
+
const keys = Object.keys(outputs);
|
|
22
|
+
if (!keys.length)
|
|
23
|
+
throw new Error('No task outputs');
|
|
24
|
+
console.log('Tasks executed:', keys);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
28
|
+
run().then(() => process.exit(0)).catch(err => { console.error(err); process.exit(1); });
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=entitlement.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement.test.js","sourceRoot":"","sources":["../../tests/entitlement.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAA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