MCPcopy Create free account
hub / github.com/Effect-TS/effect / probe

Method probe

packages/effect/src/chat/ChatTest.ts:1577–1686  ·  view source on GitHub ↗

* Calls the op behind `capability`. When the descriptor lacks it, the op * must fail with `Unsupported` naming it. When it is listed, the op must * not fail with `Unsupported` at all, whichever capability that names, so a * descriptor that lies in either direction fails.

(capability: Capability)

Source from the content-addressed store, hash-verified

1575 * descriptor that lies in either direction fails.
1576 */
1577 probe(capability: Capability): Effect.Effect<void, ConformanceFailure, Registry> {
1578 const listed = this.has(capability)
1579 const expected = listed ? "no Unsupported for listed " + capability : "Unsupported(" + capability + ")"
1580 const expect = <A>(effect: Effect.Effect<A, ChatError>, onSuccess?: (a: A) => void) =>
1581 Effect.flatMap(Effect.exit(effect), (exit) => {
1582 if (Exit.isSuccess(exit)) onSuccess?.(exit.value)
1583 const error = Exit.findErrorOption(exit)
1584 const reason = Option.isSome(error) && isChatError(error.value) ? error.value.reason : undefined
1585 const holds = listed
1586 ? Exit.isSuccess(exit) || (reason !== undefined && reason._tag !== "Unsupported")
1587 : reason?._tag === "Unsupported" && reason.capability === capability
1588 return holds ? Effect.void : Effect.fail(failure(
1589 this.rule,
1590 expected,
1591 describeExit(exit),
1592 Option.getOrUndefined(error)
1593 ))
1594 })
1595 const track = (posted: Posted) => this.track(posted)
1596 /** Whether the suite's handler was refused `Unsupported` exactly when the capability is not listed. */
1597 const checkRefusal = Effect.suspend(() => {
1598 const { refused } = this.recording
1599 const refusal = refused.find((error) => error.reason._tag === "Unsupported")
1600 return this.check(
1601 listed
1602 ? refusal === undefined
1603 : refusal?.reason._tag === "Unsupported" && refusal.reason.capability === capability,
1604 listed ? "no refusal Unsupported for listed " + capability : "a refusal Unsupported(" + capability + ")",
1605 () => refused.length === 0 ? "no refusal" : refused.map(describeError).join(", ")
1606 )
1607 })
1608 const { chat, thread } = this
1609 const text = conformanceText(this.rule)
1610 switch (capability) {
1611 case "edit":
1612 return Effect.flatMap(this.post({}), (posted) => expect(chat.edit(thread, posted.id, { markdown: text })))
1613 case "delete":
1614 return Effect.flatMap(this.post({}), (posted) => expect(chat.delete(thread, posted.id)))
1615 case "fetchMessage":
1616 return Effect.flatMap(this.post({}), (posted) => expect(chat.fetchMessage(thread, posted.id)))
1617 case "history":
1618 return expect(Stream.runDrain(Stream.take(chat.history(thread, { direction: "backward" }), 1)))
1619 case "download":
1620 return expect(Stream.runDrain(chat.download(thread, { id: "conformance-missing" }, { maxBytes: 1 })))
1621 case "files":
1622 return expect(chat.post(thread, { markdown: text, files: [conformanceFile(this.rule)] }), track)
1623 case "replyTo":
1624 return Effect.flatMap(
1625 this.post({}),
1626 (target) => expect(chat.post(thread, { markdown: text, replyTo: { messageId: target.id } }), track)
1627 )
1628 case "startThread":
1629 return Effect.flatMap(this.post({}), (posted) => expect(chat.startThread(thread, posted.id)))
1630 case "getThread":
1631 return expect(chat.getThread(thread))
1632 case "opener":
1633 return expect(chat.opener(thread))
1634 case "getUser":

Callers 2

ruleFunction · 0.95
conformanceFunction · 0.95

Calls 15

hasMethod · 0.95
checkMethod · 0.95
postMethod · 0.95
userPostsMethod · 0.95
openModalMethod · 0.95
commandMethod · 0.95
callMethod · 0.95
conformanceTextFunction · 0.85
conformanceFileFunction · 0.85
conformanceButtonFunction · 0.85
conformanceSelectFunction · 0.85
deferMethod · 0.80

Tested by

no test coverage detected