@hydraharness/harness-session-title-first-prompt-llm 0.1.1-rc.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @hydraharness/harness-session-title-first-prompt-llm
2
+
3
+ Optional `ctx.sessionTitle` provider that summarizes the first eligible human message through `ctx.llm`. It registers the `first-prompt` cadence, runs automatically only when a fresh non-fork session first creates its fallback, and attributes the result to that message's exact seq. An automatic failure retains the fallback and is retried only through `ctx.sessionTitle.refresh()`.
4
+
5
+ The plugin uses the complete required [shared LLM configuration](../session-title-llm/README.md#configuration). Omit both `provider` and `model` to inherit the exact route from the current logged main request, or set both to route title generation independently.
6
+
7
+ ## Model Experience
8
+
9
+ ### First-message title request
10
+
11
+ #### What the model sees
12
+
13
+ The title model receives the shared title instruction and a JSON array containing only the first eligible human message. Later prompts and inherited fork history do not trigger another automatic call.
14
+
15
+ #### Token effect
16
+
17
+ At most one automatic auxiliary request is made for a fresh session, bounded by `maxInputBytes` and `maxOutputTokens`; explicit refreshes may make additional calls. The main agent request gains zero tokens.
18
+
19
+ #### KV Cache effect
20
+
21
+ No main-request invalidation. The auxiliary request uses the configured or logged route and has provider-specific cache behavior.
22
+
23
+ ## Known Limitations and Deferred Work
24
+
25
+ - The first message alone may cease to represent a long-running session; use the all-messages provider when later prompts should retitle it.
26
+ - A fork keeps its inherited title and never runs this provider automatically, even when its seeded first message came from the parent.
package/lib/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import z from "@hydraharness/schemastery";
2
+ import { SessionTitleLlmConfigFields, registerSessionTitleLlmProvider } from "@hydraharness/harness-session-title-llm";
3
+ //#region lib/types/index.js
4
+ /** First-human-message model provider for `ctx.sessionTitle`. */
5
+ const name = "session-title-first-prompt-llm";
6
+ const inject = [
7
+ "sessionTitle",
8
+ "llm",
9
+ "sessions"
10
+ ];
11
+ /** Loader schema shared with the all-messages provider. */
12
+ const Config = z.object({
13
+ targetWords: SessionTitleLlmConfigFields.targetWords,
14
+ targetCjkCharacters: SessionTitleLlmConfigFields.targetCjkCharacters,
15
+ maxInputBytes: SessionTitleLlmConfigFields.maxInputBytes,
16
+ maxOutputTokens: SessionTitleLlmConfigFields.maxOutputTokens,
17
+ timeoutMs: SessionTitleLlmConfigFields.timeoutMs,
18
+ provider: SessionTitleLlmConfigFields.provider,
19
+ model: SessionTitleLlmConfigFields.model
20
+ });
21
+ /**
22
+ * Register the first-prompt model provider.
23
+ * @param ctx - context exposing session-title, LLM, and session services.
24
+ * @param config - required route, target, byte, token, and timeout policy.
25
+ */
26
+ function apply(ctx, config) {
27
+ registerSessionTitleLlmProvider(ctx, config, name, "first-prompt", (messages) => {
28
+ const first = messages[0];
29
+ if (first === void 0) throw new Error("first-prompt title provider requires one human message");
30
+ return [first];
31
+ });
32
+ }
33
+ //#endregion
34
+ export { Config, apply, inject, name };
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@hydraharness/harness-session-title-first-prompt-llm`.
4
+ * @module @hydraharness/harness-session-title-first-prompt-llm/invariant
5
+ */
6
+ const PACKAGE_NAME = "@hydraharness/harness-session-title-first-prompt-llm";
7
+ /** Cordis companion plugin name. */
8
+ const name = "session-title-first-prompt-llm-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: this thin provider delegates request and result validation to the shared
13
+ * title service and LLM helper and retains no independent mutable state.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,17 @@
1
+ /** First-human-message model provider for `ctx.sessionTitle`. */
2
+ import type { Context } from '@hydraharness/cordis';
3
+ import z from '@hydraharness/schemastery';
4
+ import type { SessionTitleLlmConfig } from '@hydraharness/harness-session-title-llm';
5
+ export declare const name = "session-title-first-prompt-llm";
6
+ export declare const inject: string[];
7
+ /** Required LLM policy; this plugin adds no defaults. */
8
+ export type Config = SessionTitleLlmConfig;
9
+ /** Loader schema shared with the all-messages provider. */
10
+ export declare const Config: z<Config>;
11
+ /**
12
+ * Register the first-prompt model provider.
13
+ * @param ctx - context exposing session-title, LLM, and session services.
14
+ * @param config - required route, target, byte, token, and timeout policy.
15
+ */
16
+ export declare function apply(ctx: Context, config: Config): void;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@hydraharness/harness-session-title-first-prompt-llm`.
3
+ * @module @hydraharness/harness-session-title-first-prompt-llm/invariant
4
+ */
5
+ import type { Context } from '@hydraharness/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "session-title-first-prompt-llm-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@hydraharness/harness-session-title-first-prompt-llm",
3
+ "description": "First-message LLM provider plugin for Hydra harness session titles",
4
+ "hydra": {
5
+ "plugin": {
6
+ "application": "Generate a conversation title from its first user prompt with the configured model."
7
+ }
8
+ },
9
+ "version": "0.1.1-rc.6",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/MaiHongPhong1902/Hydra-Harness.git",
16
+ "directory": "packages/session/session-title-first-prompt-llm"
17
+ },
18
+ "type": "module",
19
+ "main": "lib/index.js",
20
+ "types": "lib/types/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./lib/types/index.d.ts",
24
+ "default": "./lib/index.js"
25
+ },
26
+ "./invariant": {
27
+ "types": "./lib/types/invariant.d.ts",
28
+ "default": "./lib/invariant.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "lib/index.js",
34
+ "lib/invariant.js",
35
+ "lib/types/**/*.d.ts"
36
+ ],
37
+ "license": "MIT",
38
+ "peerDependencies": {
39
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
40
+ "@hydraharness/harness-session": "^0.1.1-rc.6",
41
+ "@hydraharness/harness-llm": "^0.1.1-rc.6",
42
+ "@hydraharness/harness-session-title-llm": "^0.1.1-rc.6",
43
+ "@hydraharness/cordis": "^4.0.2",
44
+ "@hydraharness/harness-session-title": "^0.1.1-rc.6"
45
+ },
46
+ "dependencies": {
47
+ "@hydraharness/schemastery": "^3.18.2"
48
+ },
49
+ "devDependencies": {
50
+ "@hydraharness/cordis-plugin-include": "^1.0.7",
51
+ "@hydraharness/cordis-plugin-loader": "^1.0.3",
52
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
53
+ "@hydraharness/harness-session": "^0.1.1-rc.6",
54
+ "@hydraharness/harness-llm": "^0.1.1-rc.6",
55
+ "@hydraharness/harness-session-title": "^0.1.1-rc.6",
56
+ "@hydraharness/harness-session-title-llm": "^0.1.1-rc.6",
57
+ "@hydraharness/cordis": "^4.0.2"
58
+ }
59
+ }