MCPcopy Create free account
hub / github.com/antirez/ds4 / agent_tool_list

Function agent_tool_list

ds4_agent.c:5776–5811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5774 unlink(tmp);
5775 free(tmp);
5776 free(text);
5777 free(path);
5778 return false;
5779 }
5780
5781 uint8_t h[DS4_KVSTORE_FIXED_HEADER];
5782 uint64_t now = (uint64_t)time(NULL);
5783 ds4_kvstore_fill_header(h, hdr.model_id, hdr.quant_bits, hdr.reason, hdr.ext_flags,
5784 stripped_token_count, hdr.hits, hdr.ctx_size,
5785 hdr.created_at, now, 0);
5786 uint8_t tb[4];
5787 ds4_kvstore_le_put32(tb, text_bytes);
5788
5789 errno = 0;
5790 ok = fwrite(h, 1, sizeof(h), fp) == sizeof(h) &&
5791 fwrite(tb, 1, sizeof(tb), fp) == sizeof(tb) &&
5792 fwrite(text, 1, text_bytes, fp) == text_bytes &&
5793 (!(hdr.ext_flags & DS4_KVSTORE_EXT_SESSION_TITLE) ||
5794 agent_kv_write_title_trailer(fp, title, err, err_len)) &&
5795 fflush(fp) == 0;
5796 int saved_errno = errno;
5797 if (fclose(fp) != 0) {
5798 if (!saved_errno) saved_errno = errno;
5799 ok = false;
5800 }
5801 if (ok && rename(tmp, path) != 0) {
5802 saved_errno = errno;
5803 ok = false;
5804 }
5805 if (!ok) {
5806 snprintf(err, err_len, "%s",
5807 saved_errno ? strerror(saved_errno) : "failed to write stripped session");
5808 unlink(tmp);
5809 } else {
5810 if (sha_out) memcpy(sha_out, sha, 41);
5811 if (tokens_out) *tokens_out = stripped_token_count;
5812 }
5813
5814 free(tmp);

Callers 1

agent_execute_tool_callFunction · 0.85

Calls 3

agent_tool_arg_valueFunction · 0.85
agent_buf_putsFunction · 0.85
agent_buf_takeFunction · 0.85

Tested by

no test coverage detected