@ossy/consultancy 3.25.0 → 3.27.0

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 (53) hide show
  1. package/README.md +7 -7
  2. package/package.json +7 -5
  3. package/src/ConsultancyNav.jsx +6 -6
  4. package/src/CreateConsultancyButton.jsx +21 -7
  5. package/src/Forecast.jsx +38 -37
  6. package/src/RequestMatches.jsx +29 -19
  7. package/src/RequestStatsPanel.jsx +1 -1
  8. package/src/ResumeMatches.jsx +51 -0
  9. package/src/calendar-quarter-months.js +36 -0
  10. package/src/calendar-quarter-months.spec.js +22 -0
  11. package/src/create-company.flow.js +9 -9
  12. package/src/current-month.component.jsx +14 -25
  13. package/src/delete-company.flow.js +5 -5
  14. package/src/en.translations.json +17 -32
  15. package/src/extract-request.task.js +20 -13
  16. package/src/extract-request.task.spec.js +7 -3
  17. package/src/file-inbound-request.task.js +93 -0
  18. package/src/file-inbound-request.task.spec.js +118 -0
  19. package/src/forecast-figures.jsx +42 -0
  20. package/src/forecast-panels.jsx +31 -42
  21. package/src/index.js +0 -1
  22. package/src/intake-categories.js +6 -22
  23. package/src/kpi-trend.component.jsx +1 -1
  24. package/src/match-reasons.js +85 -0
  25. package/src/match-reasons.spec.js +73 -0
  26. package/src/match-resumes.js +12 -7
  27. package/src/match-resumes.spec.js +13 -8
  28. package/src/match-resumes.task.js +1 -22
  29. package/src/match-resumes.task.spec.js +19 -14
  30. package/src/{consultancy.page.jsx → overview.page.jsx} +7 -7
  31. package/src/refresh-matches.js +38 -0
  32. package/src/refresh-matches.spec.js +31 -1
  33. package/src/refresh-matches.task.js +322 -72
  34. package/src/refresh-matches.task.spec.js +229 -27
  35. package/src/request.schema.js +0 -1
  36. package/src/{resume-inbound-screening.task.js → resume-inbound-requests.task.js} +12 -14
  37. package/src/{resume-inbound-screening.task.spec.js → resume-inbound-requests.task.spec.js} +32 -18
  38. package/src/resumes.page.jsx +43 -12
  39. package/src/schema-ids.js +0 -1
  40. package/src/spend-for-month.js +72 -0
  41. package/src/spend-for-month.spec.js +49 -0
  42. package/src/spend-year.jsx +91 -0
  43. package/src/{org.page.jsx → spend.page.jsx} +14 -13
  44. package/src/sv.translations.json +17 -32
  45. package/src/use-chart-months.js +5 -2
  46. package/src/use-spend-by-month.js +52 -0
  47. package/src/utilization.component.jsx +1 -1
  48. package/src/view-forecasts.flow.js +3 -3
  49. package/src/year-totals.component.jsx +1 -1
  50. package/src/Overview.jsx +0 -91
  51. package/src/company-basic-info.schema.js +0 -25
  52. package/src/screen-inbound.task.js +0 -133
  53. package/src/screen-inbound.task.spec.js +0 -154
@@ -1,15 +1,17 @@
1
1
  import { beforeEach, describe, expect, it, jest } from '@jest/globals'
2
2
 
3
3
  const getEmbedding = jest.fn()
4
- const loadWorkspaceEmbeddings = jest.fn()
4
+ const searchEmbeddings = jest.fn()
5
+ const setEmbeddingKind = jest.fn()
5
6
 
6
7
  jest.unstable_mockModule('@ossy/platform/vector/vector-store', () => ({
7
8
  getEmbedding,
8
- loadWorkspaceEmbeddings,
9
+ searchEmbeddings,
10
+ setEmbeddingKind,
9
11
  cosineSimilarity: (a, b) => (a[0] === b[0] ? 0.8 : 0.1),
10
12
  }))
11
13
 
12
- const { run } = await import('./refresh-matches.task.js')
14
+ const { metadata, run } = await import('./refresh-matches.task.js')
13
15
 
14
16
  const GetResource = { id: '@ossy/resources/actions/get' }
15
17
  const ListResources = { id: '@ossy/resources/actions/list' }
@@ -19,40 +21,112 @@ const EmbedResource = { id: '@ossy/media-tasks/actions/embed-resource' }
19
21
  const request = {
20
22
  id: 'request-1',
21
23
  type: '@ossy/consultancy/schema/request',
24
+ belongsTo: 'ws-1',
22
25
  name: 'Senior React consultant',
23
- content: { title: 'Senior React consultant', tags: ['React', 'Node.js'] },
26
+ tags: ['React', 'Node.js'],
27
+ content: { title: 'Senior React consultant' },
24
28
  }
25
29
 
26
30
  const resume = {
27
31
  id: 'resume-1',
28
32
  type: '@ossy/resumes/schema/resume',
33
+ belongsTo: 'ws-1',
29
34
  name: 'React consultant',
35
+ tags: ['React', 'Node.js'],
30
36
  content: {
31
- tags: ['React', 'Node.js'],
32
37
  profile: { resourceId: 'profile-1' },
33
38
  experiences: [],
34
39
  },
35
40
  }
36
41
 
42
+ const tagOnly = {
43
+ id: 'resume-tags',
44
+ type: '@ossy/resumes/schema/resume',
45
+ name: 'Tags only',
46
+ tags: ['React'],
47
+ content: {},
48
+ }
49
+
50
+ const vectorOnly = {
51
+ id: 'resume-vector',
52
+ type: '@ossy/resumes/schema/resume',
53
+ name: 'Vector only',
54
+ tags: ['Java'],
55
+ content: {},
56
+ }
57
+
37
58
  const profile = {
38
59
  id: 'profile-1',
39
60
  type: '@ossy/profile/schema/profile',
40
61
  content: { name: 'Ada Consultant', role: 'Senior React consultant' },
41
62
  }
42
63
 
43
- function sdkFor () {
64
+ function tagPatterns (query, found = []) {
65
+ if (!query || typeof query !== 'object') return found
66
+ if (query.tags?.$regex) found.push(query.tags.$regex)
67
+ for (const clause of query.$or || []) tagPatterns(clause, found)
68
+ return found
69
+ }
70
+
71
+ function matchesTag (item, query) {
72
+ const patterns = tagPatterns(query)
73
+ if (!patterns.length) return true
74
+ const tags = Array.isArray(item.tags) ? item.tags : []
75
+ return patterns.some((pattern) => {
76
+ const re = new RegExp(pattern, 'i')
77
+ return tags.some((tag) => re.test(tag))
78
+ })
79
+ }
80
+
81
+ function listResult (payload, pools) {
82
+ const query = payload.query || {}
83
+ let items = []
84
+ if (payload.location === '/@ossy/resumes/') items = pools.resumes
85
+ else if (payload.location === '/@ossy/consultancy/') items = pools.requests
86
+ else if (payload.location === '/@ossy/consultancy/matches/') items = pools.matches
87
+ items = items.filter((item) => !query.type || item.type === query.type)
88
+ if (query.id?.$in) items = items.filter((item) => query.id.$in.includes(item.id))
89
+ if (query['content.request.resourceId']) {
90
+ items = items.filter((item) => item.content?.request?.resourceId === query['content.request.resourceId'])
91
+ }
92
+ if (query['content.matches.resourceId']) {
93
+ items = items.filter((item) => (item.content?.matches || []).some((match) => (
94
+ match.resourceId === query['content.matches.resourceId']
95
+ )))
96
+ }
97
+ if (tagPatterns(query).length) items = items.filter((item) => matchesTag(item, query))
98
+ if (query.$or?.[0]?.['content.profile.resourceId'] || query.$or?.[0]?.['content.experiences.resourceId']) {
99
+ const profileId = query.$or.find((clause) => clause['content.profile.resourceId'])?.['content.profile.resourceId']
100
+ const experienceId = query.$or.find((clause) => clause['content.experiences.resourceId'])?.['content.experiences.resourceId']
101
+ items = items.filter((item) => (
102
+ item.content?.profile?.resourceId === profileId
103
+ || (item.content?.experiences || []).some((link) => link.resourceId === experienceId)
104
+ ))
105
+ }
106
+ const offset = Number(payload.offset) || 0
107
+ if (payload.limit != null) return items.slice(offset, offset + Number(payload.limit))
108
+ return items
109
+ }
110
+
111
+ function sdkFor (pools = {}) {
44
112
  const embedded = []
45
113
  const created = []
114
+ const data = {
115
+ requests: pools.requests || [request],
116
+ resumes: pools.resumes || [resume],
117
+ matches: pools.matches || [],
118
+ }
46
119
  return {
47
120
  embedded,
48
121
  created,
49
122
  invoke: jest.fn(async (action, payload) => {
50
- if (action.id === ListResources.id) {
51
- if (payload.location === '/@ossy/consultancy/') return [request]
52
- if (payload.location === '/@ossy/resumes/') return [resume]
53
- return []
123
+ if (action.id === ListResources.id) return listResult(payload, data)
124
+ if (action.id === GetResource.id) {
125
+ if (payload.resourceId === request.id) return request
126
+ if (payload.resourceId === resume.id) return resume
127
+ if (payload.resourceId === profile.id) return profile
128
+ return null
54
129
  }
55
- if (action.id === GetResource.id) return profile
56
130
  if (action.id === EmbedResource.id) {
57
131
  embedded.push(payload)
58
132
  return { ok: true }
@@ -66,18 +140,33 @@ function sdkFor () {
66
140
  }
67
141
  }
68
142
 
143
+ function listCalls (sdk) {
144
+ return sdk.invoke.mock.calls
145
+ .filter(([action]) => action.id === ListResources.id)
146
+ .map(([, payload]) => payload)
147
+ }
148
+
69
149
  describe('refresh-matches task', () => {
150
+ it('re-scores when a request, resume, profile, or experience is patched', () => {
151
+ const eventsFor = (type) => metadata.triggers
152
+ .filter((trigger) => trigger.type === type)
153
+ .map((trigger) => trigger.event)
154
+ expect(eventsFor('@ossy/consultancy/schema/request')).toEqual(['Created', 'Updated', 'Patched'])
155
+ expect(eventsFor('@ossy/resumes/schema/resume')).toEqual(['Created', 'Updated', 'Patched'])
156
+ expect(eventsFor('@ossy/profile/schema/profile')).toEqual(['Created', 'Updated', 'Patched'])
157
+ expect(eventsFor('@ossy/resumes/schema/resume-experience')).toEqual(['Created', 'Updated', 'Patched'])
158
+ })
159
+
70
160
  beforeEach(() => {
71
161
  getEmbedding.mockReset()
72
- loadWorkspaceEmbeddings.mockReset()
162
+ searchEmbeddings.mockReset()
163
+ setEmbeddingKind.mockReset()
73
164
  getEmbedding.mockResolvedValue(null)
74
- loadWorkspaceEmbeddings.mockResolvedValue([
75
- { resourceId: 'request-1', vector: [1] },
76
- { resourceId: 'resume-1', vector: [1] },
77
- ])
165
+ searchEmbeddings.mockResolvedValue([])
166
+ setEmbeddingKind.mockResolvedValue(undefined)
78
167
  })
79
168
 
80
- it('embeds a new request and saves its matches without embedding resumes', async () => {
169
+ it('embeds a changed request and ranks the resumes that share its tags', async () => {
81
170
  const sdk = sdkFor()
82
171
  const result = await run({
83
172
  event: {
@@ -90,8 +179,13 @@ describe('refresh-matches task', () => {
90
179
  })
91
180
 
92
181
  expect(sdk.embedded.map((item) => item.resourceId)).toEqual(['request-1'])
93
- expect(sdk.embedded[0].textHash).toEqual(expect.any(String))
94
- expect(sdk.created[0].type).toBe('@ossy/consultancy/schema/request-matches')
182
+ expect(sdk.embedded[0]).toMatchObject({ kind: 'request', textHash: expect.any(String) })
183
+ expect(searchEmbeddings).not.toHaveBeenCalled()
184
+ expect(listCalls(sdk).every((payload) => payload.query && payload.limit)).toBe(true)
185
+ expect(listCalls(sdk).some((payload) => payload.location === '/@ossy/consultancy/')).toBe(false)
186
+ expect(listCalls(sdk).some((payload) => (
187
+ payload.location === '/@ossy/resumes/' && !payload.query.tags && !payload.query.$or && !payload.query.id
188
+ ))).toBe(false)
95
189
  expect(sdk.created[0].content.matches[0]).toMatchObject({
96
190
  resourceId: 'resume-1',
97
191
  shared: ['React', 'Node.js'],
@@ -99,17 +193,123 @@ describe('refresh-matches task', () => {
99
193
  expect(result.embedded).toBe(1)
100
194
  })
101
195
 
102
- it('skips embed when the stored hash is still current', async () => {
196
+ it('keeps a tag-sharing resume that the vector search did not return', async () => {
197
+ const sdk = sdkFor({ resumes: [tagOnly, vectorOnly] })
198
+ getEmbedding.mockImplementation(async (id) => (
199
+ id === 'request-1' ? { vector: [1], kind: 'request' } : null
200
+ ))
201
+ searchEmbeddings.mockResolvedValue([{ resourceId: 'resume-vector', score: 0.4 }])
202
+
203
+ await run({
204
+ event: {
205
+ resourceId: 'request-1',
206
+ type: '@ossy/consultancy/schema/request',
207
+ event: 'Updated',
208
+ payload: { belongsTo: 'ws-1' },
209
+ },
210
+ sdk,
211
+ })
212
+
213
+ expect(searchEmbeddings).toHaveBeenCalledWith(expect.objectContaining({
214
+ workspaceId: 'ws-1',
215
+ kind: 'resume',
216
+ limit: 20,
217
+ }))
218
+ const saved = sdk.created[0].content.matches.map((item) => item.resourceId)
219
+ expect(saved).toEqual(expect.arrayContaining(['resume-tags', 'resume-vector']))
220
+ expect(sdk.created[0].content.matches.find((item) => item.resourceId === 'resume-tags').similarity).toBeNull()
221
+ })
222
+
223
+ it('pages tag-sharing resumes beyond the stored match limit before ranking', async () => {
224
+ const many = Array.from({ length: 25 }, (_, index) => ({
225
+ id: `resume-tag-${index}`,
226
+ type: '@ossy/resumes/schema/resume',
227
+ name: `Tag ${index}`,
228
+ tags: ['React'],
229
+ content: {},
230
+ }))
231
+ const sdk = sdkFor({ resumes: many })
232
+ getEmbedding.mockImplementation(async (id) => (
233
+ id === 'request-1' ? { vector: [1], kind: 'request' } : null
234
+ ))
235
+
236
+ await run({
237
+ event: {
238
+ resourceId: 'request-1',
239
+ type: '@ossy/consultancy/schema/request',
240
+ event: 'Updated',
241
+ payload: { belongsTo: 'ws-1' },
242
+ },
243
+ sdk,
244
+ })
245
+
246
+ const tagLists = listCalls(sdk).filter((payload) => (
247
+ payload.location === '/@ossy/resumes/'
248
+ && (payload.query.tags || payload.query.$or)
249
+ ))
250
+ expect(tagLists.some((payload) => payload.limit === 50)).toBe(true)
251
+ expect(tagLists.every((payload) => payload.limit !== 20)).toBe(true)
252
+ expect(sdk.created[0].content.matches).toHaveLength(20)
253
+ })
254
+
255
+ it('still saves a tag match when embedding is unavailable', async () => {
103
256
  const sdk = sdkFor()
104
- getEmbedding.mockImplementation(async (resourceId) => {
105
- const { textHash } = await import('./refresh-matches.js')
106
- const { requestMatchText, resumeMatchText } = await import('./match-resumes.js')
107
- const text = resourceId === 'request-1'
108
- ? requestMatchText(request)
109
- : resumeMatchText(resume, { profile, experiences: [] })
110
- return { textHash: textHash(text) }
257
+ sdk.invoke.mockImplementation(async (action, payload) => {
258
+ if (action.id === EmbedResource.id) {
259
+ throw Object.assign(new Error('OpenRouter integration not available'), { status: 503 })
260
+ }
261
+ if (action.id === ListResources.id) return listResult(payload, {
262
+ requests: [request],
263
+ resumes: [resume],
264
+ matches: [],
265
+ })
266
+ if (action.id === GetResource.id) return payload.resourceId === request.id ? request : null
267
+ if (action.id === CreateResource.id) {
268
+ sdk.created.push(payload)
269
+ return { id: 'match-1', content: payload.content }
270
+ }
271
+ throw new Error(action.id)
111
272
  })
112
273
 
274
+ const result = await run({
275
+ event: {
276
+ resourceId: 'request-1',
277
+ type: '@ossy/consultancy/schema/request',
278
+ event: 'Created',
279
+ payload: { belongsTo: 'ws-1' },
280
+ },
281
+ sdk,
282
+ })
283
+
284
+ expect(result.embedded).toBe(0)
285
+ expect(sdk.created[0].content.matches.map((item) => item.resourceId)).toContain('resume-1')
286
+ })
287
+
288
+ it('re-scores the requests a changed resume can affect', async () => {
289
+ const sdk = sdkFor()
290
+ getEmbedding.mockResolvedValue({ vector: [1], textHash: 'stored', kind: 'resume' })
291
+
292
+ await run({
293
+ event: {
294
+ resourceId: 'resume-1',
295
+ type: '@ossy/resumes/schema/resume',
296
+ event: 'Updated',
297
+ payload: { belongsTo: 'ws-1' },
298
+ },
299
+ sdk,
300
+ })
301
+
302
+ expect(searchEmbeddings).toHaveBeenCalledWith(expect.objectContaining({ kind: 'request' }))
303
+ expect(listCalls(sdk).filter((payload) => payload.location === '/@ossy/consultancy/').every((payload) => (
304
+ payload.query.tags || payload.query.$or || payload.query.id
305
+ ))).toBe(true)
306
+ expect(sdk.created[0].content.request).toEqual({ resourceId: 'request-1' })
307
+ })
308
+
309
+ it('does not open a resume that already has a vector on a full refresh', async () => {
310
+ const sdk = sdkFor()
311
+ getEmbedding.mockResolvedValue({ textHash: 'stored', vector: [1] })
312
+
113
313
  const result = await run({
114
314
  event: { type: 'scheduled' },
115
315
  payload: { workspaceId: 'ws-1' },
@@ -119,5 +319,7 @@ describe('refresh-matches task', () => {
119
319
  expect(sdk.embedded).toEqual([])
120
320
  expect(result.embedded).toBe(0)
121
321
  expect(sdk.created).toHaveLength(1)
322
+ expect(sdk.invoke.mock.calls.filter(([action]) => action.id === GetResource.id)).toEqual([])
323
+ expect(setEmbeddingKind).toHaveBeenCalledWith('resume-1', 'resume')
122
324
  })
123
325
  })
@@ -15,7 +15,6 @@ export default {
15
15
  { name: 'title', type: 'text', required: true, description: 'Assignment title' },
16
16
  { name: 'summary', type: 'textarea', description: 'What the client is asking for' },
17
17
  { name: 'role', type: 'text', description: 'Profile they are looking for' },
18
- { name: 'tags', type: 'tags', description: 'JSON array of skills or technologies named in the request. One string per item. Omit when the message names none.' },
19
18
  { name: 'location', type: 'text', description: 'Where the work happens' },
20
19
  { name: 'duration', type: 'text', description: 'How long the assignment lasts, in the message\'s own words' },
21
20
  { name: 'start', type: 'text', description: 'When the assignment starts, in the message\'s own words' },
@@ -1,4 +1,4 @@
1
- import { run as screenInbound } from './screen-inbound.task.js'
1
+ import { run as fileInboundRequest } from './file-inbound-request.task.js'
2
2
  import { acceptsRequestCategory } from './intake-categories.js'
3
3
 
4
4
  const ListResources = { id: '@ossy/resources/actions/list' }
@@ -8,7 +8,7 @@ const MAX_AGE_MS = 14 * 24 * 60 * 60 * 1000
8
8
  const MAX_PER_PASS = 20
9
9
 
10
10
  export const metadata = {
11
- id: '@ossy/consultancy/tasks/resume-inbound-screening',
11
+ id: '@ossy/consultancy/tasks/resume-inbound-requests',
12
12
  schedule: '*/5 * * * *',
13
13
  }
14
14
 
@@ -19,20 +19,18 @@ function asResourceList (result) {
19
19
  }
20
20
 
21
21
  /**
22
- * A message still needs screening when it has no request and no finished
23
- * intake label. A confident request label with no request means extraction
24
- * died and should be run again.
22
+ * A confident request label with no request means extraction died and should
23
+ * run again. Uncategorized mail is email's job.
25
24
  *
26
25
  * @param {object | null | undefined} resource
27
26
  * @param {number} [now]
28
27
  */
29
- export function needsInboundScreening (resource, now = Date.now()) {
28
+ export function needsInboundRequestFiling (resource, now = Date.now()) {
30
29
  if (resource?.type !== INBOUND_MESSAGE) return false
31
30
  const content = resource.content && typeof resource.content === 'object' ? resource.content : {}
32
31
  if (content.requestId) return false
33
32
  const received = Date.parse(content.receivedAt || '')
34
33
  if (!Number.isNaN(received) && now - received > MAX_AGE_MS) return false
35
- if (!Object.hasOwn(content, 'intakeCategory')) return true
36
34
  return acceptsRequestCategory({
37
35
  category: content.intakeCategory,
38
36
  confidence: content.intakeConfidence,
@@ -40,7 +38,7 @@ export function needsInboundScreening (resource, now = Date.now()) {
40
38
  }
41
39
 
42
40
  /**
43
- * Finish inbound mail whose screening was interrupted. One pass per workspace.
41
+ * Finish confident consultancy-request labels whose extract step was interrupted.
44
42
  */
45
43
  export async function run ({ payload, req, sdk, log }) {
46
44
  if (!sdk?.invoke) throw Object.assign(new Error('sdk is required'), { status: 500 })
@@ -53,25 +51,25 @@ export async function run ({ payload, req, sdk, log }) {
53
51
  workspaceId,
54
52
  })
55
53
  const pending = asResourceList(listed)
56
- .filter((resource) => needsInboundScreening(resource))
54
+ .filter((resource) => needsInboundRequestFiling(resource))
57
55
  .slice(0, MAX_PER_PASS)
58
56
 
59
- let screened = 0
57
+ let filed = 0
60
58
  let failed = 0
61
59
  for (const message of pending) {
62
60
  try {
63
- await screenInbound({
61
+ await fileInboundRequest({
64
62
  event: { resourceId: message.id, payload: { belongsTo: workspaceId } },
65
63
  payload: { resourceId: message.id, workspaceId },
66
64
  req,
67
65
  sdk,
68
66
  })
69
- screened += 1
67
+ filed += 1
70
68
  } catch (error) {
71
69
  failed += 1
72
- log?.error('[consultancy/tasks/resume-inbound-screening] message failed', { resourceId: message.id }, error)
70
+ log?.error('[consultancy/tasks/resume-inbound-requests] message failed', { resourceId: message.id }, error)
73
71
  }
74
72
  }
75
73
 
76
- return { screened, failed }
74
+ return { filed, failed }
77
75
  }
@@ -1,57 +1,71 @@
1
- import { metadata, needsInboundScreening, run } from './resume-inbound-screening.task.js'
1
+ import { metadata, needsInboundRequestFiling, run } from './resume-inbound-requests.task.js'
2
2
  import { REQUEST_CATEGORY } from './intake-categories.js'
3
3
 
4
+ /** Stay inside the 14-day resume window regardless of when CI runs. */
5
+ const recentReceivedAt = () => new Date(Date.now() - 60 * 60 * 1000).toISOString()
6
+
4
7
  const message = {
5
8
  id: 'msg-1',
6
9
  type: '@ossy/email/schema/inbound-message',
10
+ belongsTo: 'ws-1',
7
11
  content: {
8
12
  from: 'client@studio.se',
9
13
  subject: 'SDK',
10
14
  text: 'Vi behöver en specialist.',
11
- receivedAt: '2026-10-17T17:56:46.000Z',
15
+ receivedAt: recentReceivedAt(),
16
+ intakeCategory: REQUEST_CATEGORY,
17
+ intakeConfidence: 1,
12
18
  },
13
19
  }
14
20
 
15
- describe('resume-inbound-screening', () => {
21
+ describe('resume-inbound-requests', () => {
16
22
  it('runs every five minutes', () => {
23
+ expect(metadata.id).toBe('@ossy/consultancy/tasks/resume-inbound-requests')
17
24
  expect(metadata.schedule).toBe('*/5 * * * *')
18
25
  })
19
26
 
20
- it('selects mail that never finished screening', () => {
27
+ it('selects confident request labels that never got a request', () => {
21
28
  const now = Date.parse('2026-10-17T19:00:00.000Z')
22
- expect(needsInboundScreening(message, now)).toBe(true)
23
- expect(needsInboundScreening({
29
+ expect(needsInboundRequestFiling(message, now)).toBe(true)
30
+ expect(needsInboundRequestFiling({
24
31
  ...message,
25
32
  content: { ...message.content, intakeCategory: 'contact', intakeConfidence: 0.9 },
26
33
  }, now)).toBe(false)
27
- expect(needsInboundScreening({
34
+ expect(needsInboundRequestFiling({
28
35
  ...message,
29
- content: { ...message.content, intakeCategory: REQUEST_CATEGORY, intakeConfidence: 1 },
30
- }, now)).toBe(true)
31
- expect(needsInboundScreening({
36
+ content: {
37
+ from: 'client@studio.se',
38
+ subject: 'SDK',
39
+ text: 'Vi behöver en specialist.',
40
+ receivedAt: recentReceivedAt(),
41
+ },
42
+ }, now)).toBe(false)
43
+ expect(needsInboundRequestFiling({
32
44
  ...message,
33
45
  content: { ...message.content, requestId: 'request-1' },
34
46
  }, now)).toBe(false)
35
- expect(needsInboundScreening({
47
+ expect(needsInboundRequestFiling({
36
48
  ...message,
37
49
  content: { ...message.content, receivedAt: '2026-01-01T00:00:00.000Z' },
38
50
  }, now)).toBe(false)
39
51
  })
40
52
 
41
- it('screens only the unfinished message', async () => {
53
+ it('files only the unfinished request', async () => {
42
54
  const calls = []
43
- const settled = {
55
+ const contact = {
44
56
  ...message,
45
- id: 'msg-settled',
57
+ id: 'msg-contact',
46
58
  content: { ...message.content, intakeCategory: 'contact', intakeConfidence: 1 },
47
59
  }
48
60
  const sdk = {
49
61
  async invoke (action, payload) {
50
62
  calls.push({ id: action.id, payload })
51
- if (action.id === '@ossy/resources/actions/list') return [settled, message]
63
+ if (action.id === '@ossy/resources/actions/list') return [contact, message]
52
64
  if (action.id === '@ossy/resources/actions/get') return message
53
- if (action.id === '@ossy/media-tasks/actions/categorize') return { category: 'contact', confidence: 0.95 }
54
- if (action.id === '@ossy/resources/actions/update-content') return { ...message, content: payload.content }
65
+ if (action.id === '@ossy/consultancy/actions/extract-request') return { id: 'request-1' }
66
+ if (action.id === '@ossy/resources/actions/update-content') {
67
+ return { ...message, content: payload.content }
68
+ }
55
69
  throw new Error(`unexpected ${action.id}`)
56
70
  },
57
71
  }
@@ -61,7 +75,7 @@ describe('resume-inbound-screening', () => {
61
75
  sdk,
62
76
  })
63
77
 
64
- expect(result).toEqual({ screened: 1, failed: 0 })
78
+ expect(result).toEqual({ filed: 1, failed: 0 })
65
79
  const gets = calls.filter((call) => call.id === '@ossy/resources/actions/get')
66
80
  expect(gets.map((call) => call.payload.resourceId)).toEqual(['msg-1'])
67
81
  })
@@ -1,8 +1,13 @@
1
1
  import React, { useMemo, useRef } from 'react'
2
- import { DropZone, Icon, List, Page, Tags, Text, View } from '@ossy/design-system'
2
+ import { Button, DropZone, Icon, List, Page, Tags, Text, View, useLocale } from '@ossy/design-system'
3
3
  import { AsyncStatus } from '@ossy/sdk-react'
4
4
  import { useRouter } from '@ossy/router-react'
5
- import { ListPanelLayout, listPanelPageProps } from '@ossy/resources'
5
+ import {
6
+ ListPanelLayout,
7
+ ResourcePanel,
8
+ listPanelPageProps,
9
+ useSelectedResourceId,
10
+ } from '@ossy/resources'
6
11
  import {
7
12
  ResumeFileInput,
8
13
  ResumeImportMenuItem,
@@ -13,6 +18,7 @@ import {
13
18
  import { ConsultancyNav } from './ConsultancyNav.jsx'
14
19
  import { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
15
20
  import { Definition } from './Definition.js'
21
+ import { ResumeMatches } from './ResumeMatches.jsx'
16
22
 
17
23
  export const metadata = {
18
24
  id: 'consultancy/resumes',
@@ -29,18 +35,18 @@ function resumeLabel (resource) {
29
35
  }
30
36
 
31
37
  function resumeTags (resource) {
32
- const value = resource?.content?.tags
33
- if (!Array.isArray(value)) return ''
34
- return value
35
- .filter((item) => typeof item === 'string' && item.trim())
36
- .join(', ')
38
+ const value = resource?.tags
39
+ if (!Array.isArray(value)) return []
40
+ return value.filter((item) => typeof item === 'string' && item.trim())
37
41
  }
38
42
 
39
43
  export const ConsultancyResumesPage = () => {
40
44
  const router = useRouter()
45
+ const { t } = useLocale()
41
46
  const fileRef = useRef(null)
42
47
  const { jobs, importFiles, busy } = useImportResumes()
43
48
  const { resumes, status } = useResumes()
49
+ const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
44
50
  const statusTags = (Definition.status ?? [])
45
51
  .map((item) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[item]))
46
52
  .filter(Boolean)
@@ -94,15 +100,26 @@ export const ConsultancyResumesPage = () => {
94
100
  return (
95
101
  <List.Item
96
102
  key={resource.id}
97
- href={router.getHref({
98
- id: '@resume',
99
- params: { resumeId: resource.id, workspaceId: router.params.workspaceId },
100
- })}
103
+ selectable
104
+ selected={resource.id === selectedResourceId}
105
+ onClick={() => setSelectedResourceId(resource.id)}
101
106
  data-resource-name={label || undefined}
102
107
  leading={(
103
108
  <Icon size="s" name="document" style={{ fill: 'hsl(0, 0%, 80%)' }} />
104
109
  )}
105
- meta={tags ? <Text variant="small">{tags}</Text> : null}
110
+ meta={tags.length ? <Tags tags={tags} size="s" gap="xs" /> : null}
111
+ trailing={(
112
+ <Button
113
+ variant="command"
114
+ prefix="external"
115
+ aria-label={t('consultancy.resumes.openEditor')}
116
+ href={router.getHref({
117
+ id: '@resume',
118
+ params: { resumeId: resource.id, workspaceId: router.params.workspaceId },
119
+ })}
120
+ onClick={(event) => event.stopPropagation()}
121
+ />
122
+ )}
106
123
  >
107
124
  {label}
108
125
  </List.Item>
@@ -111,6 +128,20 @@ export const ConsultancyResumesPage = () => {
111
128
  </List>
112
129
  </View>
113
130
  )}
131
+ panel={selectedResourceId
132
+ ? (
133
+ <ResourcePanel
134
+ width="100%"
135
+ resourceId={selectedResourceId}
136
+ onClose={clearSelectedResourceId}
137
+ extraPanels={[{
138
+ id: 'panel-resume-matches',
139
+ label: t('consultancy.matches.requestsTitle'),
140
+ content: ResumeMatches,
141
+ }]}
142
+ />
143
+ )
144
+ : null}
114
145
  />
115
146
  </View>
116
147
  </DropZone>
package/src/schema-ids.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /** Canonical schema ids for @ossy/consultancy (ADR 0006). */
2
2
  export const ConsultancySchema = Object.freeze({
3
- companyBasicInfo: '@ossy/consultancy/schema/company-basic-info',
4
3
  contract: '@ossy/consultancy/schema/contract',
5
4
  employee: '@ossy/consultancy/schema/employee',
6
5
  vacation: '@ossy/consultancy/schema/vacation',