@indexnetwork/protocol 65.0.0 → 66.0.0-rc.609.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/CHANGELOG.md +10 -0
- package/IMPLEMENTATION.md +11 -12
- package/STABILITY.md +0 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +3 -6
- package/dist/internal/opportunities/opportunity.cards.d.ts +78 -0
- package/dist/internal/opportunities/opportunity.cards.js +165 -0
- package/dist/internal/opportunities/opportunity.graph.modes.d.ts +0 -1
- package/dist/internal/opportunities/opportunity.graph.modes.js +0 -5
- package/dist/internal/opportunities/opportunity.labels.d.ts +0 -2
- package/dist/internal/opportunities/opportunity.labels.js +0 -2
- package/dist/internal/opportunities/opportunity.presentation.d.ts +21 -185
- package/dist/internal/opportunities/opportunity.presentation.js +35 -651
- package/dist/internal/opportunities/opportunity.utils.d.ts +0 -42
- package/dist/internal/opportunities/opportunity.utils.js +0 -102
- package/dist/platform/database/capabilities.d.ts +2 -2
- package/dist/platform/database/entities.d.ts +1 -1
- package/package.json +1 -1
- package/dist/internal/opportunities/opportunity.feed-selection.d.ts +0 -24
- package/dist/internal/opportunities/opportunity.feed-selection.js +0 -40
- package/dist/internal/opportunities/radar/radar.graph.d.ts +0 -230
- package/dist/internal/opportunities/radar/radar.graph.js +0 -537
- package/dist/internal/opportunities/radar/radar.state.d.ts +0 -88
- package/dist/internal/opportunities/radar/radar.state.js +0 -87
- package/dist/internal/shared/utils/claim-safety.d.ts +0 -24
- package/dist/internal/shared/utils/claim-safety.js +0 -88
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Annotation } from '@langchain/langgraph';
|
|
2
|
-
/**
|
|
3
|
-
* Radar Graph State (Annotation-based).
|
|
4
|
-
* Flow: loadOpportunities → checkPresenterCache → [generateCardText if misses]
|
|
5
|
-
* → cachePresenterResults → normalizeItems.
|
|
6
|
-
*/
|
|
7
|
-
export const RadarGraphState = Annotation.Root({
|
|
8
|
-
userId: Annotation({
|
|
9
|
-
reducer: (curr, next) => next ?? curr,
|
|
10
|
-
default: () => '',
|
|
11
|
-
}),
|
|
12
|
-
networkId: Annotation({
|
|
13
|
-
reducer: (curr, next) => next ?? curr,
|
|
14
|
-
default: () => undefined,
|
|
15
|
-
}),
|
|
16
|
-
scopeType: Annotation({
|
|
17
|
-
reducer: (curr, next) => next ?? curr,
|
|
18
|
-
default: () => undefined,
|
|
19
|
-
}),
|
|
20
|
-
scopeId: Annotation({
|
|
21
|
-
reducer: (curr, next) => next ?? curr,
|
|
22
|
-
default: () => undefined,
|
|
23
|
-
}),
|
|
24
|
-
limit: Annotation({
|
|
25
|
-
reducer: (curr, next) => next ?? curr,
|
|
26
|
-
default: () => 50,
|
|
27
|
-
}),
|
|
28
|
-
/** When true, bypass the presenter Redis cache. */
|
|
29
|
-
noCache: Annotation({
|
|
30
|
-
reducer: (curr, next) => next ?? curr,
|
|
31
|
-
default: () => false,
|
|
32
|
-
}),
|
|
33
|
-
/**
|
|
34
|
-
* Presentation depth. 'full' (default) runs the presenter LLM for cache
|
|
35
|
-
* misses. 'skeleton' skips it: uncached cards come back with resolved
|
|
36
|
-
* identity (name/avatar/status) and `presentationPending: true`, cached
|
|
37
|
-
* cards come back complete.
|
|
38
|
-
*/
|
|
39
|
-
presentation: Annotation({
|
|
40
|
-
reducer: (curr, next) => next ?? curr,
|
|
41
|
-
default: () => 'full',
|
|
42
|
-
}),
|
|
43
|
-
/** Optional status filter. When undefined, the graph uses `DEFAULT_RADAR_STATUSES`. */
|
|
44
|
-
statuses: Annotation({
|
|
45
|
-
reducer: (curr, next) => next ?? curr,
|
|
46
|
-
default: () => undefined,
|
|
47
|
-
}),
|
|
48
|
-
/** Raw opportunities visible to the viewer (after visibility filter). */
|
|
49
|
-
opportunities: Annotation({
|
|
50
|
-
reducer: (curr, next) => next ?? curr,
|
|
51
|
-
default: () => [],
|
|
52
|
-
}),
|
|
53
|
-
/** Cards with presenter output and narrator chip. */
|
|
54
|
-
cards: Annotation({
|
|
55
|
-
reducer: (curr, next) => next ?? curr,
|
|
56
|
-
default: () => [],
|
|
57
|
-
}),
|
|
58
|
-
/** Final items for response (internal fields stripped). */
|
|
59
|
-
items: Annotation({
|
|
60
|
-
reducer: (curr, next) => next ?? curr,
|
|
61
|
-
default: () => [],
|
|
62
|
-
}),
|
|
63
|
-
/** Presenter results retrieved from cache (opportunityId → RadarCardItem). */
|
|
64
|
-
cachedCards: Annotation({
|
|
65
|
-
reducer: (curr, next) => next ?? curr,
|
|
66
|
-
default: () => new Map(),
|
|
67
|
-
}),
|
|
68
|
-
/** Opportunities that had no cache hit and need presenter generation. */
|
|
69
|
-
uncachedOpportunities: Annotation({
|
|
70
|
-
reducer: (curr, next) => next ?? curr,
|
|
71
|
-
default: () => [],
|
|
72
|
-
}),
|
|
73
|
-
error: Annotation({
|
|
74
|
-
reducer: (curr, next) => next ?? curr,
|
|
75
|
-
default: () => undefined,
|
|
76
|
-
}),
|
|
77
|
-
/** Meta for response (e.g. totalOpportunities). */
|
|
78
|
-
meta: Annotation({
|
|
79
|
-
reducer: (curr, next) => next ?? curr,
|
|
80
|
-
default: () => ({ totalOpportunities: 0 }),
|
|
81
|
-
}),
|
|
82
|
-
/** Timing records for each agent invocation within this graph run. */
|
|
83
|
-
agentTimings: Annotation({
|
|
84
|
-
reducer: (acc, val) => [...acc, ...val],
|
|
85
|
-
default: () => [],
|
|
86
|
-
}),
|
|
87
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic guard for unsupported person-affiliation and presence claims.
|
|
3
|
-
*
|
|
4
|
-
* Opportunity presentation contracts currently do not carry typed provenance
|
|
5
|
-
* proving attendance, membership, residence, or shared presence. The guard
|
|
6
|
-
* therefore fails closed: a sentence making one of those claims is rejected
|
|
7
|
-
* rather than loosely "grounded" against network/context text.
|
|
8
|
-
*
|
|
9
|
-
* The patterns are deliberately phrase-based. They target factual claims such
|
|
10
|
-
* as "Alice is a member of..." while leaving generic domain phrases such as
|
|
11
|
-
* "membership model" and "team members" alone. This is not a general factuality
|
|
12
|
-
* checker and does not attempt semantic inference beyond the listed claim
|
|
13
|
-
* families.
|
|
14
|
-
*/
|
|
15
|
-
/** Returns true when text contains an unsupported affiliation/presence claim. */
|
|
16
|
-
export declare function hasUnsupportedOpportunityClaim(text: string | null | undefined): boolean;
|
|
17
|
-
/** Returns true when one sentence contains an unsupported claim family. */
|
|
18
|
-
export declare function isUnsupportedOpportunityClaimSentence(sentence: string): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Removes complete sentences containing unsupported claims and preserves the
|
|
21
|
-
* remaining sentence order. An all-unsafe input becomes an empty string so the
|
|
22
|
-
* caller can apply a field-specific deterministic default.
|
|
23
|
-
*/
|
|
24
|
-
export declare function stripUnsupportedOpportunityClaims(text: string | null | undefined): string;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic guard for unsupported person-affiliation and presence claims.
|
|
3
|
-
*
|
|
4
|
-
* Opportunity presentation contracts currently do not carry typed provenance
|
|
5
|
-
* proving attendance, membership, residence, or shared presence. The guard
|
|
6
|
-
* therefore fails closed: a sentence making one of those claims is rejected
|
|
7
|
-
* rather than loosely "grounded" against network/context text.
|
|
8
|
-
*
|
|
9
|
-
* The patterns are deliberately phrase-based. They target factual claims such
|
|
10
|
-
* as "Alice is a member of..." while leaving generic domain phrases such as
|
|
11
|
-
* "membership model" and "team members" alone. This is not a general factuality
|
|
12
|
-
* checker and does not attempt semantic inference beyond the listed claim
|
|
13
|
-
* families.
|
|
14
|
-
*/
|
|
15
|
-
const UNSUPPORTED_CLAIM_PATTERNS = [
|
|
16
|
-
// Attendance and co-attendance claims. Relational grammar avoids product
|
|
17
|
-
// phrases such as "attendee management".
|
|
18
|
-
/\b(?:co[-\s]?attendance|co[-\s]?attendee(?:s)?|co[-\s]?attend(?:ed|ing)?|(?:another|fellow)\s+(?:(?:event|session|conference|summit|gathering|meetup)\s+)?attendees?)\b/i,
|
|
19
|
-
/\b(?:is|are|was|were|will be|has been|have been|as)\s+(?:an?\s+)?attendees?\b/i,
|
|
20
|
-
/\b(?:a|an|this|that)\s+attendee\s+(?:of|at)\b/i,
|
|
21
|
-
/\b(?:will\s+|plans?\s+to\s+)?attend(?:ed|ing)?\s+(?!to\b)(?:(?:at|in)\s+)?(?:the\s+)?[\p{L}\p{N}&'’.-]+\b/iu,
|
|
22
|
-
/\b(?:is|are|was|were|will be)\s+going\s+to\s+(?:the\s+)?(?:event|session|conference|summit|gathering|meetup|[A-Z][\p{L}\p{N}&'’.-]*)\b/u,
|
|
23
|
-
/\b(?:[Pp]articipat(?:ed|ing)|[Pp]articipants?)\b(?=.{0,40}\b(?:in|at)\s+(?:the\s+)?(?:event|session|conference|summit|gathering|meetup|[A-Z][\p{L}\p{N}&'’.-]*))/u,
|
|
24
|
-
/\b(?:[Ww]ent\s+to|[Tt]ook\s+part\s+in|(?:[Ww]as|[Ww]ere|[Ii]s|[Aa]re)\s+present\s+at)\s+(?:the\s+)?(?:event|session|conference|summit|gathering|meetup|[A-Z][\p{L}\p{N}&'’.-]*)\b/u,
|
|
25
|
-
/\b(?:session\s+attendance|attendance\s+(?:at|in)\s+(?:the\s+)?(?:event|session|conference|summit|gathering|meetup))\b/i,
|
|
26
|
-
// Shared event/session/place/time claims, including "both were at ...".
|
|
27
|
-
/\b(?:same|the same)\s+(?:event|session|place|location|venue|time)\b/i,
|
|
28
|
-
/\b(?:share|shared|sharing)\s+(?:an?\s+|the\s+)?(?:event|session|workshop|conference|summit|gathering|meetup|place|location|venue|time)\b/i,
|
|
29
|
-
/\bboth\s+(?:were|are|will be|have been)\s+(?:at|in|during)\b/i,
|
|
30
|
-
/\b(?:were|are|will be|have been)\s+both\s+(?:at|in|during)\b/i,
|
|
31
|
-
/\b(?:will|would|are|were)\s+both\s+be?\s*(?:at|in|during)\b/i,
|
|
32
|
-
/\bboth\b.{0,80}\b(?:attend(?:ed|ing)?|participat(?:e|ed|ing)|met|meet|meeting|stayed|stay)\b.{0,60}\b(?:event|session|place|location|venue|time)\b/i,
|
|
33
|
-
// Factual membership/affiliation claims. Generic descriptions of product
|
|
34
|
-
// users ("members of cooperatives") and "team members" stay untouched.
|
|
35
|
-
/\b(?:is|are|was|were|be|being|been|became|become|as)\s+(?:an?\s+)?(?:fellow\s+)?members?\s+(?:of|in)\b/i,
|
|
36
|
-
/\b(?:another|fellow)\s+members?\b/i,
|
|
37
|
-
/\b(?:is|are|was|were|be|being|been|as)\s+(?:an?\s+)?(?:community|network|event)\s+members?\b/i,
|
|
38
|
-
/\b(?:a|an|this|that)\s+(?:fellow\s+)?member\s+(?:of|in)\b/i,
|
|
39
|
-
/\b(?:is|are|was|were|be|being|been)\s+(?:an?\s+)?part\s+of\s+(?:the\s+)?[^.!?]{0,60}\b(?:community|network|event)\b/i,
|
|
40
|
-
/\bfellow\s+members?\s+(?:of|in)\b/i,
|
|
41
|
-
/\b(?:a|an)\s+(?:[A-Z][\p{L}\p{N}&'’.-]*\s+){1,6}(?:community\s+|network\s+)?member\b/u,
|
|
42
|
-
/\b(?:[Bb]elongs?|[Bb]elonged)\s+to\s+(?:the\s+)?(?:[Nn]etwork|[Cc]ommunity|[Ee]vent|(?:[A-Z][\p{L}\p{N}&'’.-]*\s+){1,5}[A-Z][\p{L}\p{N}&'’.-]*)\b/u,
|
|
43
|
-
/\b[Jj]oined\s+(?:the\s+)?(?:[Nn]etwork|[Cc]ommunity|[Ee]vent|(?:[A-Z][\p{L}\p{N}&'’.-]*\s+){1,5}[A-Z][\p{L}\p{N}&'’.-]*)\b/u,
|
|
44
|
-
/\b[Aa]ffiliated\s+with\s+(?:the\s+)?(?:[Nn]etwork|[Cc]ommunity|[Ee]vent|[A-Z][\p{L}\p{N}&'’.-]*)\b/u,
|
|
45
|
-
// Residence/co-residence claims. Require person-claim grammar so generic
|
|
46
|
-
// audience descriptions such as "tools for residents of Berlin" survive.
|
|
47
|
-
/\b(?:is|are|was|were|be|being|been|as)\s+(?:an?\s+)?(?:local\s+|long[-\s]?time\s+|co[-\s]?)?residents?\b/i,
|
|
48
|
-
/\bco[-\s]?(?:reside|resides|resided|residing)\b/i,
|
|
49
|
-
/\b(?:another|fellow)\s+residents?\b/i,
|
|
50
|
-
/\b(?:a|an|this|that)\s+(?:co[-\s]?)?resident\s+(?:of|in)\b/i,
|
|
51
|
-
/\b(?:a|an)\s+(?:[A-Z][\p{L}\p{N}&'’.-]*\s+){1,6}(?:co[-\s]?)?resident\b/u,
|
|
52
|
-
/\b(?:[Hh]e|[Ss]he|[Tt]hey|[A-Z][\p{L}'’.-]+)\s+(?:reside|resides|resided|residing|live|lives|lived|living|(?:is|are|was|were)\s+based)\s+in\b/u,
|
|
53
|
-
/\b(?:[Hh]e|[Ss]he|[Tt]hey|[A-Z][\p{L}'’.-]+)\s+calls?\s+[A-Z][\p{L}\p{N}&'’.-]*(?:\s+[A-Z][\p{L}\p{N}&'’.-]*){0,5}\s+home\b/u,
|
|
54
|
-
// Relationship claims inferred from shared network/event placement.
|
|
55
|
-
/\b(?:know|knows|knew|met|meet)\b.{0,60}\b(?:through|from|at)\s+(?:the\s+)?(?:network|community|event|session)\b/i,
|
|
56
|
-
/\bcrossed\s+paths\s+(?:at|during)\b/i,
|
|
57
|
-
];
|
|
58
|
-
/** Returns true when text contains an unsupported affiliation/presence claim. */
|
|
59
|
-
export function hasUnsupportedOpportunityClaim(text) {
|
|
60
|
-
if (!text?.trim())
|
|
61
|
-
return false;
|
|
62
|
-
return splitClaimSentences(text).some(isUnsupportedOpportunityClaimSentence);
|
|
63
|
-
}
|
|
64
|
-
/** Returns true when one sentence contains an unsupported claim family. */
|
|
65
|
-
export function isUnsupportedOpportunityClaimSentence(sentence) {
|
|
66
|
-
return UNSUPPORTED_CLAIM_PATTERNS.some((pattern) => pattern.test(sentence));
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Removes complete sentences containing unsupported claims and preserves the
|
|
70
|
-
* remaining sentence order. An all-unsafe input becomes an empty string so the
|
|
71
|
-
* caller can apply a field-specific deterministic default.
|
|
72
|
-
*/
|
|
73
|
-
export function stripUnsupportedOpportunityClaims(text) {
|
|
74
|
-
if (!text?.trim())
|
|
75
|
-
return "";
|
|
76
|
-
return splitClaimSentences(text)
|
|
77
|
-
.filter((sentence) => !isUnsupportedOpportunityClaimSentence(sentence))
|
|
78
|
-
.join(" ")
|
|
79
|
-
.replace(/\s+/g, " ")
|
|
80
|
-
.trim();
|
|
81
|
-
}
|
|
82
|
-
function splitClaimSentences(text) {
|
|
83
|
-
return text
|
|
84
|
-
.trim()
|
|
85
|
-
.split(/(?<=[.!?])\s+|\n+/)
|
|
86
|
-
.map((sentence) => sentence.trim())
|
|
87
|
-
.filter(Boolean);
|
|
88
|
-
}
|