@try-works/extension-laya 0.0.0-stage → 1.0.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.
Files changed (43) hide show
  1. package/README.md +38 -2
  2. package/lib/index.d.ts +18 -0
  3. package/lib/index.js +172 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/pure.d.ts +35 -0
  6. package/lib/pure.js +71 -0
  7. package/lib/pure.js.map +1 -0
  8. package/models.lock.json +63 -0
  9. package/package.json +39 -4
  10. package/schema/decision-choose.input.json +22 -0
  11. package/schema/decision-choose.output.json +20 -0
  12. package/schema/decision-score.input.json +18 -0
  13. package/schema/decision-score.output.json +18 -0
  14. package/schema/decision-test.input.json +10 -0
  15. package/schema/decision-test.output.json +18 -0
  16. package/tool-mode.extension.json +87 -0
  17. package/vendor/LICENSE.laya-ts +176 -0
  18. package/vendor/laya-ts/agent.d.ts +216 -0
  19. package/vendor/laya-ts/agent.js +631 -0
  20. package/vendor/laya-ts/common.d.ts +167 -0
  21. package/vendor/laya-ts/common.js +478 -0
  22. package/vendor/laya-ts/dx.d.ts +17 -0
  23. package/vendor/laya-ts/dx.js +46 -0
  24. package/vendor/laya-ts/email.d.ts +2 -0
  25. package/vendor/laya-ts/email.js +184 -0
  26. package/vendor/laya-ts/hooks.d.ts +134 -0
  27. package/vendor/laya-ts/hooks.js +379 -0
  28. package/vendor/laya-ts/index.d.ts +22 -0
  29. package/vendor/laya-ts/index.js +13 -0
  30. package/vendor/laya-ts/lang.d.ts +24 -0
  31. package/vendor/laya-ts/lang.js +590 -0
  32. package/vendor/laya-ts/presets.d.ts +5 -0
  33. package/vendor/laya-ts/presets.js +175 -0
  34. package/vendor/laya-ts/providers.d.ts +67 -0
  35. package/vendor/laya-ts/providers.js +668 -0
  36. package/vendor/laya-ts/router.d.ts +186 -0
  37. package/vendor/laya-ts/router.js +757 -0
  38. package/vendor/laya-ts/shortlist.d.ts +65 -0
  39. package/vendor/laya-ts/shortlist.js +407 -0
  40. package/vendor/laya-ts/structured.d.ts +89 -0
  41. package/vendor/laya-ts/structured.js +256 -0
  42. package/vendor/laya-ts/tokenizer.d.ts +66 -0
  43. package/vendor/laya-ts/tokenizer.js +482 -0
@@ -0,0 +1,175 @@
1
+ export function triageQuestions() {
2
+ return {
3
+ intent: {
4
+ type: "choice",
5
+ instructions: "What does the customer want in `message`?",
6
+ criteria: {
7
+ refund: "money returned or a duplicate charge reversed",
8
+ technical_help: "a bug, outage or integration problem",
9
+ billing_question: "a question about an invoice, plan or payment method",
10
+ information: "general information, pricing or how-to",
11
+ cancellation: "wants to cancel or downgrade",
12
+ other: "none of the other options fits",
13
+ },
14
+ },
15
+ is_urgent: {
16
+ type: "noul",
17
+ instructions: "Does `message` communicate time pressure or a deadline?",
18
+ },
19
+ frustration: {
20
+ type: "score",
21
+ instructions: "How frustrated does the customer sound in `message`?",
22
+ criteria: [
23
+ "calm and neutral",
24
+ "concerned but civil",
25
+ "clearly annoyed",
26
+ "very angry or using strong language",
27
+ ],
28
+ },
29
+ refund_requested: {
30
+ type: "noul",
31
+ instructions: "Does the customer ask for money back?",
32
+ },
33
+ churn_risk: {
34
+ type: "noul",
35
+ instructions: "Does `message` suggest the customer may leave for a competitor or cancel?",
36
+ },
37
+ };
38
+ }
39
+ export function emailQuestions(categories) {
40
+ const cats = categories ?? {
41
+ billing: "invoices, payments, refunds",
42
+ technical: "bugs, outages, integrations",
43
+ sales: "pricing, demos, new purchases",
44
+ security: "phishing, scams, account compromise",
45
+ hr: "hiring, leave, payroll",
46
+ other: "none of the above",
47
+ };
48
+ return {
49
+ category: {
50
+ type: "choice",
51
+ instructions: "Which team should handle the email in `body`?",
52
+ criteria: cats,
53
+ },
54
+ is_spam: {
55
+ type: "noul",
56
+ instructions: "Is this email unsolicited spam or bulk marketing?",
57
+ },
58
+ is_phishing: {
59
+ type: "noul",
60
+ instructions: "Is this email a phishing or scam attempt to steal money, credentials, or personal data?",
61
+ criteria: { true: "phishing, scam, or fraud", false: "a legitimate email" },
62
+ },
63
+ urgency: {
64
+ type: "score",
65
+ instructions: "How urgent is the request in `body`?",
66
+ criteria: ["no time pressure", "needs attention soon", "blocking issue or hard deadline"],
67
+ },
68
+ needs_reply: {
69
+ type: "noul",
70
+ instructions: "Does the sender expect a reply?",
71
+ },
72
+ };
73
+ }
74
+ export function guardQuestions() {
75
+ return {
76
+ jailbreak: {
77
+ type: "noul",
78
+ instructions: "Does `prompt` try to make an AI assistant ignore its rules, policies or system instructions?",
79
+ },
80
+ prompt_injection: {
81
+ type: "noul",
82
+ instructions: "Does `prompt` contain instructions aimed at the AI system rather than a genuine user request?",
83
+ },
84
+ sensitive_data: {
85
+ type: "noul",
86
+ instructions: "Does `prompt` contain credentials, personal data or other sensitive information?",
87
+ },
88
+ harm_severity: {
89
+ type: "score",
90
+ instructions: "How much harm would complying with `prompt` cause?",
91
+ criteria: [
92
+ "none: ordinary request",
93
+ "minor: mildly inappropriate",
94
+ "serious: unsafe advice or abuse",
95
+ "severe: dangerous or illegal",
96
+ ],
97
+ },
98
+ topic: {
99
+ type: "choice",
100
+ instructions: "What is `prompt` about?",
101
+ criteria: {
102
+ product_support: null,
103
+ coding: null,
104
+ general_knowledge: null,
105
+ personal_advice: null,
106
+ security_testing: null,
107
+ other: null,
108
+ },
109
+ },
110
+ };
111
+ }
112
+ export function moderationQuestions() {
113
+ return {
114
+ toxic: {
115
+ type: "noul",
116
+ instructions: "Is `post` toxic: rude, disrespectful or likely to make someone leave the discussion?",
117
+ },
118
+ harassment: {
119
+ type: "noul",
120
+ instructions: "Does `post` target or harass a specific person?",
121
+ },
122
+ threat: {
123
+ type: "noul",
124
+ instructions: "Does `post` threaten violence, harm or intimidation?",
125
+ },
126
+ spam: {
127
+ type: "noul",
128
+ instructions: "Is `post` spam or advertising?",
129
+ },
130
+ severity: {
131
+ type: "score",
132
+ instructions: "How severe is any rule-breaking in `post`?",
133
+ criteria: [
134
+ "no rule-breaking: ordinary on-topic post",
135
+ "mild: rude tone or off-topic, no target",
136
+ "clear violation: insults, harassment or spam aimed at someone",
137
+ "severe: threats, hate speech or calls for violence",
138
+ ],
139
+ },
140
+ };
141
+ }
142
+ export function routerQuestions() {
143
+ return {
144
+ difficulty: {
145
+ type: "score",
146
+ instructions: "How hard is `request` for a language model?",
147
+ criteria: [
148
+ "trivial: a lookup or one-liner",
149
+ "easy: short answer, no reasoning",
150
+ "moderate: several steps",
151
+ "hard: long multi-step reasoning or specialist knowledge",
152
+ ],
153
+ },
154
+ domain: {
155
+ type: "choice",
156
+ instructions: "What domain does `request` belong to?",
157
+ criteria: {
158
+ code: "software engineering, programming, refactoring, architecture, debugging",
159
+ math_or_logic: "mathematics, logic puzzles, proofs, complex calculation",
160
+ writing: "creative writing, essays, emails, blog posts, copywriting",
161
+ factual_lookup: "facts, definitions, trivia, history",
162
+ data_analysis: "statistics, SQL, data manipulation, metrics",
163
+ chitchat: "casual conversation, greetings, small talk",
164
+ },
165
+ },
166
+ needs_tools: {
167
+ type: "noul",
168
+ instructions: "Does answering `request` require external tools, search or private data?",
169
+ },
170
+ is_sensitive: {
171
+ type: "noul",
172
+ instructions: "Does `request` involve money, legal, medical or safety consequences?",
173
+ },
174
+ };
175
+ }
@@ -0,0 +1,67 @@
1
+ /** ONNX session shim: Node (onnxruntime-node) + browser (onnxruntime-web).
2
+ * Lazy imports only — unit tests with a fake provider never touch onnxruntime. */
3
+ /** Opt-in reviewed commit SHAs of the published checkpoints (mirror of laya/revisions.py).
4
+ * They are not applied implicitly, so existing Hub/offline caches keep working. */
5
+ export declare const PINNED_REVISIONS: Record<string, string>;
6
+ /** Return an explicit revision unchanged; otherwise preserve the Hub default and cache. */
7
+ export declare function resolveRevision(_repoOrId: string, revision?: string | null): string | null;
8
+ export interface Batch {
9
+ inputIds: number[][];
10
+ attentionMask: number[][];
11
+ markerPos: number[][];
12
+ markerMask: boolean[][];
13
+ qtype: number[];
14
+ }
15
+ export interface SessionProvider {
16
+ runEncoder(batch: Batch): Promise<{
17
+ lastHidden: number[][][];
18
+ }>;
19
+ runHead(hidden: number[][][] | unknown, batch: Batch): Promise<{
20
+ logits: number[][];
21
+ act: number[][];
22
+ }>;
23
+ }
24
+ /** Encoder feeds: input_ids + attention_mask (int64). */
25
+ export declare function feed(ort: any, b: Batch): Record<string, any>;
26
+ /** Head feeds: encoder hidden + marker_pos/mask + qtype. */
27
+ export declare function feedHead(ort: any, hidden: number[][][] | any, b: Batch): Record<string, any>;
28
+ export interface ProviderOptions {
29
+ device?: string;
30
+ numThreads?: number;
31
+ /** Opt-in {artifact name: SHA-256 hexdigest} check for fetched ONNX files (web). */
32
+ expectedSha256?: Record<string, string>;
33
+ signal?: AbortSignal | null;
34
+ onProgress?: ((done: number, total: number, file: string) => void) | null;
35
+ }
36
+ export interface NodeBundle {
37
+ dir: string;
38
+ cfg: any;
39
+ tokenizerJson: unknown | null;
40
+ /** Commit SHA the artifacts came from (pinned/requested, or the hub's `x-repo-commit`); null for local dirs. */
41
+ revision: string | null;
42
+ }
43
+ export declare function loadNodeBundle(modelDirOrRepo: string, opts?: {
44
+ subfolder?: string | null;
45
+ localDir?: string;
46
+ token?: string | null;
47
+ revision?: string | null;
48
+ expectedSha256?: Record<string, string>;
49
+ signal?: AbortSignal | null;
50
+ onProgress?: ((done: number, total: number, file: string) => void) | null;
51
+ }): Promise<NodeBundle>;
52
+ export interface WebBundle {
53
+ dir: string;
54
+ cfg: any;
55
+ tokenizerJson: unknown | null;
56
+ /** Pinned/requested commit SHA, if any (full-URL sources have no implicit revision). */
57
+ revision: string | null;
58
+ }
59
+ export declare function loadWebBundle(repoOrUrl: string, opts?: {
60
+ subfolder?: string | null;
61
+ revision?: string | null;
62
+ expectedSha256?: Record<string, string>;
63
+ signal?: AbortSignal | null;
64
+ onProgress?: ((done: number, total: number, file: string) => void) | null;
65
+ }): Promise<WebBundle>;
66
+ export declare function createNodeProvider(modelDir: string, opts?: ProviderOptions): Promise<SessionProvider>;
67
+ export declare function createWebProvider(modelUrl: string, opts?: ProviderOptions): Promise<SessionProvider>;