@indexnetwork/protocol 66.0.0-rc.643.1 → 66.0.0-rc.645.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/index.d.ts CHANGED
@@ -32,6 +32,8 @@ export type { NetworkPulseSummary, NetworkPulseSummaryInput } from "./internal/n
32
32
  export type { NetworksDeps } from "./capabilities/networks.js";
33
33
  export { Intents } from "./capabilities/intents.js";
34
34
  export type { PrepareAnswer, PrepareInput, PrepareResult, RecoveryField, RecoveryFieldKind, RecoveryFieldOption, IntentsDeps, IntentSemanticMetadata, PreparedIntent, } from "./capabilities/intents.js";
35
+ export { IntentSuggester } from "./internal/intents/intent.suggester.js";
36
+ export type { IntentSuggestion, IntentSuggestionInput } from "./internal/intents/intent.suggester.js";
35
37
  export { normalizeTelegramHandle } from './internal/shared/utils/telegram-handle.js';
36
38
  /**
37
39
  * opportunity — the capability's sole cross-capability surface.
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ export { NetworkPulseSummarizer } from "./internal/networks/network.pulse-summar
36
36
  // The whole capability behind one class: lifecycle graph, verification, and
37
37
  // payload preparation.
38
38
  export { Intents } from "./capabilities/intents.js";
39
+ export { IntentSuggester } from "./internal/intents/intent.suggester.js";
39
40
  // ─── Agents ───────────────────────────────────────────────────────────────────
40
41
  export { normalizeTelegramHandle } from './internal/shared/utils/telegram-handle.js';
41
42
  // ─── Opportunity compatibility exports ─────────────────────────────────────
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ export declare const IntentSuggestionOutputSchema: z.ZodObject<{
3
+ lookingFor: z.ZodArray<z.ZodString, "many">;
4
+ offering: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ lookingFor: string[];
7
+ offering: string;
8
+ }, {
9
+ lookingFor: string[];
10
+ offering: string;
11
+ }>;
12
+ export interface IntentSuggestionInput {
13
+ name: string | null;
14
+ intro: string | null;
15
+ location: string | null;
16
+ /** The person's active intents, so no suggestion repeats one. */
17
+ existingIntents: string[];
18
+ }
19
+ /** One suggested first intent; `kind` says which side of a match it is on. */
20
+ export interface IntentSuggestion {
21
+ kind: "looking_for" | "offering";
22
+ text: string;
23
+ }
24
+ /**
25
+ * Suggests a new member's first intents from their profile: two they might be
26
+ * looking for and one they could offer. Follows the shared agent pattern:
27
+ * structured output, `invokeWithAbortSignal`, null on error.
28
+ */
29
+ export declare class IntentSuggester {
30
+ private model;
31
+ constructor();
32
+ /**
33
+ * @param input - The person's profile and their active intents.
34
+ * @returns Two "looking_for" suggestions then one "offering", or null when the call fails.
35
+ */
36
+ invoke(input: IntentSuggestionInput): Promise<IntentSuggestion[] | null>;
37
+ }
@@ -0,0 +1,100 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { HumanMessage, SystemMessage } from "@langchain/core/messages";
11
+ import { z } from "zod";
12
+ import { log } from "../shared/observability/log.js";
13
+ import { Timed } from "../shared/observability/performance.js";
14
+ import { createStructuredModel } from "../shared/agent/model.config.js";
15
+ import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
16
+ // ─── Response schema ───────────────────────────────────────────────────────────
17
+ const SuggestionText = z
18
+ .string()
19
+ .describe("One line, at most 90 characters, in the person's own voice, lowercase, no trailing period.");
20
+ export const IntentSuggestionOutputSchema = z.object({
21
+ lookingFor: z
22
+ .array(SuggestionText)
23
+ .describe("Exactly two things they might want: someone to learn from, hire, fund, build with, or meet."),
24
+ offering: SuggestionText.describe("One thing they could offer others: their skills, capital, time, or help."),
25
+ });
26
+ // ─── Logger ───────────────────────────────────────────────────────────────────
27
+ const logger = log.lib.from("IntentSuggester");
28
+ // ─── System prompt ────────────────────────────────────────────────────────────
29
+ const systemPrompt = `
30
+ You are someone's agent on Index, a network where an agent finds the right people for its
31
+ person by matching intents: what they are looking for and what they can offer.
32
+
33
+ TASK:
34
+ They just joined. From their profile, suggest three intents they could start with:
35
+ - two things they might be looking for (someone to learn from, hire, fund, build with, or meet)
36
+ - one thing they could offer (their skills, capital, time, or help)
37
+
38
+ RULES:
39
+ - Write each in their voice, first person implied, like they would type it:
40
+ "looking for a technical cofounder who has shipped ml in production",
41
+ "happy to give early founders feedback on their go-to-market".
42
+ - Ground every suggestion in the profile: their work, field, stage, and place. Be concrete
43
+ enough that the right person would recognize themselves, but do not invent facts.
44
+ - One line each, at most 90 characters, lowercase, no trailing period, no emoji, no em dashes.
45
+ - Skip anything that repeats one of their existing intents.
46
+ - If the profile says little, still give three plausible, specific starting points.
47
+ `;
48
+ // ─── Agent class ──────────────────────────────────────────────────────────────
49
+ /**
50
+ * Suggests a new member's first intents from their profile: two they might be
51
+ * looking for and one they could offer. Follows the shared agent pattern:
52
+ * structured output, `invokeWithAbortSignal`, null on error.
53
+ */
54
+ export class IntentSuggester {
55
+ constructor() {
56
+ this.model = createStructuredModel("suggestionGenerator", IntentSuggestionOutputSchema, {
57
+ name: "intent_suggestions",
58
+ });
59
+ }
60
+ /**
61
+ * @param input - The person's profile and their active intents.
62
+ * @returns Two "looking_for" suggestions then one "offering", or null when the call fails.
63
+ */
64
+ async invoke(input) {
65
+ const clean = (text, max) => (text ?? "").replace(/\s+/g, " ").trim().slice(0, max);
66
+ const prompt = [
67
+ `## Name\n${clean(input.name, 200) || "(unknown)"}`,
68
+ `## Location\n${clean(input.location, 200) || "(unknown)"}`,
69
+ `## Intro\n${clean(input.intro, 4000) || "(empty)"}`,
70
+ `## Existing intents\n${input.existingIntents.map((s) => `- ${clean(s, 400)}`).join("\n") || "(none)"}`,
71
+ ].join("\n\n");
72
+ try {
73
+ const result = await invokeWithAbortSignal(this.model, [new SystemMessage(systemPrompt), new HumanMessage(prompt)]);
74
+ const parsed = IntentSuggestionOutputSchema.safeParse(result);
75
+ if (!parsed.success) {
76
+ logger.error("Schema validation failed", { error: parsed.error });
77
+ return null;
78
+ }
79
+ const tidy = (text) => text.replace(/\s+/g, " ").trim().replace(/\.$/, "");
80
+ const lookingFor = parsed.data.lookingFor.map(tidy).filter(Boolean).slice(0, 2);
81
+ const offering = tidy(parsed.data.offering);
82
+ if (lookingFor.length < 2 || !offering)
83
+ return null;
84
+ return [
85
+ ...lookingFor.map((text) => ({ kind: "looking_for", text })),
86
+ { kind: "offering", text: offering },
87
+ ];
88
+ }
89
+ catch (error) {
90
+ logger.error("Error during execution", { error });
91
+ return null;
92
+ }
93
+ }
94
+ }
95
+ __decorate([
96
+ Timed(),
97
+ __metadata("design:type", Function),
98
+ __metadata("design:paramtypes", [Object]),
99
+ __metadata("design:returntype", Promise)
100
+ ], IntentSuggester.prototype, "invoke", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "66.0.0-rc.643.1",
3
+ "version": "66.0.0-rc.645.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",