@husk-ai/sessions 0.1.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/chat.d.ts +11 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +2 -0
- package/dist/chat.js.map +1 -0
- package/dist/distill.d.ts +130 -0
- package/dist/distill.d.ts.map +1 -0
- package/dist/distill.js +773 -0
- package/dist/distill.js.map +1 -0
- package/dist/distiller.d.ts +18 -0
- package/dist/distiller.d.ts.map +1 -0
- package/dist/distiller.js +23 -0
- package/dist/distiller.js.map +1 -0
- package/dist/formatter.d.ts +8 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +11 -0
- package/dist/formatter.js.map +1 -0
- package/dist/importers/chatgpt.d.ts +12 -0
- package/dist/importers/chatgpt.d.ts.map +1 -0
- package/dist/importers/chatgpt.js +223 -0
- package/dist/importers/chatgpt.js.map +1 -0
- package/dist/importers/claude.d.ts +37 -0
- package/dist/importers/claude.d.ts.map +1 -0
- package/dist/importers/claude.js +512 -0
- package/dist/importers/claude.js.map +1 -0
- package/dist/importers/cursor.d.ts +12 -0
- package/dist/importers/cursor.d.ts.map +1 -0
- package/dist/importers/cursor.js +229 -0
- package/dist/importers/cursor.js.map +1 -0
- package/dist/importers/fsutil.d.ts +22 -0
- package/dist/importers/fsutil.d.ts.map +1 -0
- package/dist/importers/fsutil.js +79 -0
- package/dist/importers/fsutil.js.map +1 -0
- package/dist/importers/gemini.d.ts +13 -0
- package/dist/importers/gemini.d.ts.map +1 -0
- package/dist/importers/gemini.js +228 -0
- package/dist/importers/gemini.js.map +1 -0
- package/dist/importers/index.d.ts +70 -0
- package/dist/importers/index.d.ts.map +1 -0
- package/dist/importers/index.js +258 -0
- package/dist/importers/index.js.map +1 -0
- package/dist/importers/markdown.d.ts +14 -0
- package/dist/importers/markdown.d.ts.map +1 -0
- package/dist/importers/markdown.js +188 -0
- package/dist/importers/markdown.js.map +1 -0
- package/dist/importers/universal.d.ts +16 -0
- package/dist/importers/universal.d.ts.map +1 -0
- package/dist/importers/universal.js +106 -0
- package/dist/importers/universal.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +151 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +109 -0
- package/dist/prompts.js.map +1 -0
- package/dist/redactor.d.ts +38 -0
- package/dist/redactor.d.ts.map +1 -0
- package/dist/redactor.js +144 -0
- package/dist/redactor.js.map +1 -0
- package/dist/scaffold.d.ts +40 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +0 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/serialize.d.ts +15 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +122 -0
- package/dist/serialize.js.map +1 -0
- package/package.json +28 -0
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatRequest, ChatResponse } from '@husk-ai/core';
|
|
2
|
+
/**
|
|
3
|
+
* The only thing this package needs from a model.
|
|
4
|
+
*
|
|
5
|
+
* `ModelRouter` from @husk-ai/models satisfies it, and so does a three-line stub in
|
|
6
|
+
* a test, which is the point: nothing here opens a socket on its own.
|
|
7
|
+
*/
|
|
8
|
+
export interface ChatLike {
|
|
9
|
+
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC/C"}
|
package/dist/chat.js
ADDED
package/dist/chat.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { DistilledAgent, HuskSpec, HuskSpecInput, Transcript, TranscriptMessage } from '@husk-ai/core';
|
|
2
|
+
import type { ChatLike } from './chat.js';
|
|
3
|
+
interface DirectivePattern {
|
|
4
|
+
re: RegExp;
|
|
5
|
+
weight: number;
|
|
6
|
+
kind: 'identity' | 'rule' | 'preference' | 'style';
|
|
7
|
+
}
|
|
8
|
+
export declare const DIRECTIVES: DirectivePattern[];
|
|
9
|
+
/**
|
|
10
|
+
* Real user turns: what a person typed, with the plumbing removed.
|
|
11
|
+
*
|
|
12
|
+
* When the importer recorded `promptSource` -- Claude Code does -- that field is
|
|
13
|
+
* authoritative and the text heuristics are skipped. It is the difference
|
|
14
|
+
* between a prompt the user wrote and a skill document the harness pasted in
|
|
15
|
+
* wearing the user's role.
|
|
16
|
+
*/
|
|
17
|
+
export declare function humanTurns(messages: TranscriptMessage[]): TranscriptMessage[];
|
|
18
|
+
export interface MinedRule {
|
|
19
|
+
text: string;
|
|
20
|
+
kind: DirectivePattern['kind'];
|
|
21
|
+
occurrences: number;
|
|
22
|
+
score: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Standing instructions, ranked.
|
|
26
|
+
*
|
|
27
|
+
* Recurrence is the signal that matters: a sentence the user typed once might be
|
|
28
|
+
* about today's task, and one they typed four times is how they want to be
|
|
29
|
+
* worked with.
|
|
30
|
+
*/
|
|
31
|
+
export declare function mineRules(messages: TranscriptMessage[], limit?: number): MinedRule[];
|
|
32
|
+
/**
|
|
33
|
+
* The quality floor for a knowledge item.
|
|
34
|
+
*
|
|
35
|
+
* Everything here is a way of asking one question: would this still be true,
|
|
36
|
+
* and still be useful, in a conversation that happens next week? A tool-use id
|
|
37
|
+
* would not. A temp path would not. "Agent X finished" would not.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isUsableKnowledge(title: string, content: string): boolean;
|
|
40
|
+
export declare function mineKnowledge(messages: TranscriptMessage[], limit?: number): Array<{
|
|
41
|
+
title: string;
|
|
42
|
+
content: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Exchanges worth imitating.
|
|
46
|
+
*
|
|
47
|
+
* A turn the user immediately corrected is a counter-example, so it is excluded
|
|
48
|
+
* rather than held up as how the bot should behave.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mineExamples(messages: TranscriptMessage[], limit?: number): Array<{
|
|
51
|
+
user: string;
|
|
52
|
+
assistant: string;
|
|
53
|
+
}>;
|
|
54
|
+
export interface ObservedTools {
|
|
55
|
+
raw: string[];
|
|
56
|
+
bundles: string[];
|
|
57
|
+
suggested: string[];
|
|
58
|
+
needsComputer: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function observedTools(transcript: Transcript): ObservedTools;
|
|
61
|
+
export interface HeuristicOptions {
|
|
62
|
+
maxRules?: number;
|
|
63
|
+
maxKnowledge?: number;
|
|
64
|
+
maxExamples?: number;
|
|
65
|
+
/** Scrub secrets, home paths and emails from the result. Default true. */
|
|
66
|
+
redact?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* No model, no network, no key. Mines the transcript for standing instructions,
|
|
70
|
+
* durable facts, uncorrected exchanges and observed tools.
|
|
71
|
+
*/
|
|
72
|
+
export declare function distillHeuristic(transcript: Transcript, opts?: HeuristicOptions): DistilledAgent;
|
|
73
|
+
/** Map an observed provider model id onto a Husk alias. Unknown ids stay unset. */
|
|
74
|
+
export declare function modelAlias(model: string): string | undefined;
|
|
75
|
+
export interface ModelDistillOptions extends HeuristicOptions {
|
|
76
|
+
model?: string;
|
|
77
|
+
/** Rough token budget per map window. */
|
|
78
|
+
windowTokens?: number;
|
|
79
|
+
/** Messages of context repeated at each window boundary. */
|
|
80
|
+
overlap?: number;
|
|
81
|
+
concurrency?: number;
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Split the whole transcript into windows.
|
|
86
|
+
*
|
|
87
|
+
* Every message lands in exactly one window plus an overlap. Nothing is dropped:
|
|
88
|
+
* truncating a 500-message transcript to its first 50 throws away the part where
|
|
89
|
+
* the user finally explained what they wanted.
|
|
90
|
+
*/
|
|
91
|
+
export declare function windowMessages(messages: TranscriptMessage[], windowTokens: number, overlap: number): TranscriptMessage[][];
|
|
92
|
+
/**
|
|
93
|
+
* Map over every window to extract candidates, then one reduce pass to merge.
|
|
94
|
+
* Any failure degrades to `distillHeuristic` rather than throwing.
|
|
95
|
+
*/
|
|
96
|
+
export declare function distillWithModel(transcript: Transcript, router: ChatLike, opts?: ModelDistillOptions): Promise<DistilledAgent>;
|
|
97
|
+
/** Model path when a router is given, free path otherwise. */
|
|
98
|
+
export declare function distill(transcript: Transcript, opts?: ModelDistillOptions & {
|
|
99
|
+
router?: ChatLike;
|
|
100
|
+
}): Promise<DistilledAgent>;
|
|
101
|
+
export interface ToSpecOverrides extends Partial<HuskSpecInput> {
|
|
102
|
+
/** Provenance. Filled from the transcript when omitted. */
|
|
103
|
+
transcript?: Transcript;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `suggestedTools` is advisory; `spec.tools` is executable.
|
|
107
|
+
*
|
|
108
|
+
* The transcript contributes whatever the host tool happened to call things --
|
|
109
|
+
* `Bash`, `WebFetch`, `mcp__foo__bar` -- and the model path lets the model add
|
|
110
|
+
* more. Writing those through verbatim produces a husk.yaml that validates and
|
|
111
|
+
* then resolves to nothing at run time, which is the worst of both. Names are
|
|
112
|
+
* mapped onto bundles, unrecognised ones are dropped, and a husk always ends up
|
|
113
|
+
* with at least one tool.
|
|
114
|
+
*/
|
|
115
|
+
export declare function normaliseTools(suggested: string[], needsComputer: boolean): string[];
|
|
116
|
+
/**
|
|
117
|
+
* Turn a distilled agent into a spec that `parseSpec` accepts, every time.
|
|
118
|
+
* Names are slugged, strings are clamped to the schema's limits, and `origin`
|
|
119
|
+
* records where the husk came from.
|
|
120
|
+
*
|
|
121
|
+
* This is the **only** `DistilledAgent -> HuskSpec` mapper. The CLI's
|
|
122
|
+
* `specFromDistilled` and the server's `/v1/sessions/distill` both call it, so a
|
|
123
|
+
* husk distilled at the terminal and the same husk distilled over HTTP are the
|
|
124
|
+
* same file. They were not: the two call sites wrote `metadata.distilledConfidence`
|
|
125
|
+
* and `metadata.distillConfidence` respectively, and disagreed about what
|
|
126
|
+
* `origin.source` meant.
|
|
127
|
+
*/
|
|
128
|
+
export declare function toSpec(agent: DistilledAgent, overrides?: ToSpecOverrides): HuskSpec;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=distill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distill.d.ts","sourceRoot":"","sources":["../src/distill.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAWvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAwC1C,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC;CACpD;AAED,eAAO,MAAM,UAAU,EAAE,gBAAgB,EAkCxC,CAAC;AAyBF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,EAAE,CAS7E;AAmCD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAA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